using Myshipping.Core; using Furion.DependencyInjection; using Furion.DynamicApiController; using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; using System.Linq; using System.Threading.Tasks; using Myshipping.Core.Entity; using Microsoft.Extensions.Logging; namespace Myshipping.Core.Service { /// /// 接口授权服务 /// [ApiDescriptionSettings(Name = "DjyApiAuth", Order = 1)] public class DjyApiAuthService : IDjyApiAuthService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; private readonly ILogger _logger; public DjyApiAuthService(SqlSugarRepository rep, ILogger logger) { _rep = rep; _logger = logger; } /// /// 分页查询接口授权 /// /// /// [HttpGet("/DjyApiAuth/page")] public async Task Page([FromQuery] QueryDjyApiAuthInput input) { var entities = await _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.ApiCode), u => u.ApiCode == input.ApiCode) .WhereIF(!string.IsNullOrWhiteSpace(input.ApiName), u => u.ApiName == input.ApiName) .WhereIF(!string.IsNullOrWhiteSpace(input.TenantName), u => u.TenantName == input.TenantName) .WhereIF(!string.IsNullOrWhiteSpace(input.UserName), u => u.UserName == input.UserName) .WhereIF(input.IsDisable.HasValue, u => u.IsDisable == input.IsDisable.Value) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 保存授权 /// /// /// [HttpPost("/DjyApiAuth/sava")] public async Task Save(SaveDjyApiAuthInput input) { DjyApiAuth entity = null; if (input.Id > 0) { entity = input.Adapt(); await _rep.InsertAsync(entity); } else { entity = _rep.AsQueryable().Filter(null, true).First(x => x.Id == input.Id); input.Adapt(entity); await _rep.UpdateAsync(entity); } return entity.Id; } /// /// 删除接口授权 /// /// /// [HttpPost("/DjyApiAuth/delete")] public async Task Delete(GetDjyApiAuthInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 获取接口授权 /// /// /// [HttpGet("/DjyApiAuth/detail")] public async Task Get([FromQuery] GetDjyApiAuthInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } ///// ///// 获取接口授权列表 ///// ///// ///// //[HttpGet("/DjyApiAuth/list")] //public async Task List([FromQuery] QueryDjyApiAuthInput input) //{ // return await _rep.ToListAsync(); //} } }