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.

99 lines
3.3 KiB

12 months ago
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 = "ServiceConfig", Order = 1)]
public class ServiceConfigService : IServiceConfigService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<ServiceConfig> _rep;
public ServiceConfigService(SqlSugarRepository<ServiceConfig> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询业务配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/ServiceConfig/page")]
public async Task<dynamic> Page([FromQuery] ServiceConfigInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name == input.Name)
.WhereIF(!string.IsNullOrWhiteSpace(input.Value), u => u.Value == input.Value)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加业务配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/ServiceConfig/add")]
public async Task Add(AddServiceConfigInput input)
{
var entity = input.Adapt<ServiceConfig>();
await _rep.InsertAsync(entity);
}
/// <summary>
/// 删除业务配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/ServiceConfig/delete")]
public async Task Delete(DeleteServiceConfigInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 更新业务配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/ServiceConfig/edit")]
public async Task Update(UpdateServiceConfigInput input)
{
var entity = input.Adapt<ServiceConfig>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
/// <summary>
/// 获取业务配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/ServiceConfig/Detail")]
12 months ago
public async Task<ServiceConfig> Get([FromQuery] QueryeServiceConfigInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取业务配置列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/ServiceConfig/list")]
public async Task<dynamic> List([FromQuery] ServiceConfigInput input)
{
return await _rep.ToListAsync();
}
}
}