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 Microsoft.Extensions.Logging; using Furion.FriendlyException; using Myshipping.Core.Entity; namespace Myshipping.Core.Service { /// /// 钉钉客服通知群配置服务 /// [ApiDescriptionSettings(Name = "DjyDingtalkGroupConfig", Order = 1)] public class DjyDingtalkGroupConfigService : IDjyDingtalkGroupConfigService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; private readonly ILogger _logger; public DjyDingtalkGroupConfigService(SqlSugarRepository rep, ILogger logger) { _rep = rep; _logger = logger; } /// /// 分页查询钉钉客服通知群配置 /// /// /// [HttpGet("/DjyDingtalkGroupConfig/page")] public async Task Page([FromQuery] QueryDjyDingtalkGroupConfigInput input) { var entities = await _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code == input.Code) .WhereIF(!string.IsNullOrWhiteSpace(input.Desp), u => u.Desp.Contains(input.Desp.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.Keyword.Contains(input.Keyword.Trim())) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 增加钉钉客服通知群配置 /// /// /// [HttpPost("/DjyDingtalkGroupConfig/add")] public async Task Add(AddDjyDingtalkGroupConfigInput input) { var cc = _rep.Count(x => x.Code == input.Code); if (cc > 0) { throw Oops.Bah("代码重复"); } var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 更新钉钉客服通知群配置 /// /// /// [HttpPost("/DjyDingtalkGroupConfig/edit")] public async Task Update(UpdateDjyDingtalkGroupConfigInput input) { var cc = _rep.Count(x => x.Code == input.Code && x.Id != input.Id); if (cc > 0) { throw Oops.Bah("代码重复"); } var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } /// /// 删除钉钉客服通知群配置 /// /// /// [HttpPost("/DjyDingtalkGroupConfig/delete")] public async Task Delete(GetDjyDingtalkGroupConfigInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 获取钉钉客服通知群配置 /// /// /// [HttpGet("/DjyDingtalkGroupConfig/detail")] public async Task Get([FromQuery] GetDjyDingtalkGroupConfigInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } ///// ///// 获取钉钉客服通知群配置列表 ///// ///// ///// //[HttpGet("/DjyDingtalkGroupConfig/list")] //public async Task List([FromQuery] QueryDjyDingtalkGroupConfigInput input) //{ // return await _rep.ToListAsync(); //} } }