using GDZZ.Core; using Furion.DependencyInjection; using Furion.DynamicApiController; using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; using System.Linq; using System.Threading.Tasks; using GDZZ.Application.Entity; using Microsoft.AspNetCore.Authorization; namespace GDZZ.Application { /// /// 活动广告列表服务 /// [ApiDescriptionSettings("Application",Name = "MiniBanner", Order = 1)] public class MiniBannerService : IMiniBannerService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; public MiniBannerService(SqlSugarRepository rep) { _rep = rep; } /// /// 分页查询活动广告列表 /// /// /// [HttpGet("/Mini/BannePpage")] public async Task Page([FromQuery] MiniBannerInput input) { var entities = await _rep.AsQueryable() .Where(u => u.Type == input.Type) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 增加活动广告列表 /// /// /// [HttpPost("/Mini/BannerAdd")] public async Task Add(AddMiniBannerInput input) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 删除活动广告列表 /// /// /// [HttpPost("/Mini/BannerDelete")] public async Task Delete(DeleteMiniBannerInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 更新活动广告列表 /// /// /// [HttpPost("/Mini/BannerEdit")] public async Task Update(UpdateMiniBannerInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync(); } /// /// 获取活动广告详情 /// /// /// [HttpGet("/Mini/BannerDetail")] public async Task Get([FromQuery] QueryeMiniBannerInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } /// /// 获取活动广告列表列表 /// /// /// [HttpGet("/Mini/GetBannerList")] [AllowAnonymous] public async Task List([FromQuery] MiniBannerInput input) { return await _rep.Where(u => u.Type == input.Type).ToListAsync(); } } }