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
{
///
/// 套餐管理服务
///
[ApiDescriptionSettings("Application",Name = "MiniThali", Order = 1)]
public class MiniThaliService : IMiniThaliService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
public MiniThaliService(SqlSugarRepository rep)
{
_rep = rep;
}
///
/// 分页查询套餐管理
///
///
///
[HttpGet("/MiniThali/page")]
public async Task Page([FromQuery] MiniThaliInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
///
/// 增加套餐管理
///
///
///
[HttpPost("/MiniThali/add")]
public async Task Add(AddMiniThaliInput input)
{
var entity = input.Adapt();
await _rep.InsertAsync(entity);
}
///
/// 删除套餐管理
///
///
///
[HttpPost("/MiniThali/delete")]
public async Task Delete(DeleteMiniThaliInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
///
/// 更新套餐管理
///
///
///
[HttpPost("/MiniThali/edit")]
public async Task Update(UpdateMiniThaliInput input)
{
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
///
/// 获取套餐管理
///
///
///
[HttpGet("/MiniThali/detail")]
public async Task Get([FromQuery] QueryeMiniThaliInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
///
/// 获取套餐管理列表
///
///
///
[HttpGet("/MiniThali/list")]
public async Task List([FromQuery] MiniThaliInput input)
{
return await _rep.ToListAsync();
}
}
}