You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

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;
namespace GDZZ.Application
{
/// <summary>
/// 活动广告列表服务
/// </summary>
[ApiDescriptionSettings("Application",Name = "MiniBanner", Order = 1)]
public class MiniBannerService : IMiniBannerService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<MiniBanner> _rep;
public MiniBannerService(SqlSugarRepository<MiniBanner> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询活动广告列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/BannePpage")]
public async Task<dynamic> Page([FromQuery] MiniBannerInput input)
{
var entities = await _rep.AsQueryable()
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加活动广告列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/Mini/BannerAdd")]
public async Task Add(AddMiniBannerInput input)
{
var entity = input.Adapt<MiniBanner>();
await _rep.InsertAsync(entity);
}
/// <summary>
/// 删除活动广告列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/Mini/BannerDelete")]
public async Task Delete(DeleteMiniBannerInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 更新活动广告列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/Mini/BannerEdit")]
public async Task Update(UpdateMiniBannerInput input)
{
var entity = input.Adapt<MiniBanner>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
/// <summary>
/// 获取活动广告详情
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/BannerDetail")]
public async Task<MiniBanner> Get([FromQuery] QueryeMiniBannerInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取活动广告列表列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/GetBannerList")]
public async Task<dynamic> List([FromQuery] MiniBannerInput input)
{
return await _rep.ToListAsync();
}
}
}