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 System.Collections.Generic; using Myshipping.Core.Entity; namespace Myshipping.Core.Service { /// /// 租户参数 /// [ApiDescriptionSettings(Name = "DJYTenantParam", Order = 1)] public class DjyTenantParamService : IDjyTenantParamService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _itemrep; private readonly SqlSugarRepository _valuerep; private readonly ILogger _logger; public DjyTenantParamService(SqlSugarRepository rep, SqlSugarRepository itemrep, SqlSugarRepository valuerep, ILogger logger) { _rep = rep; _logger = logger; _itemrep = itemrep; _valuerep = valuerep; } /// /// 增加租户参数类别表 /// /// [HttpPost("/DJYTenantParam/add")] public async Task Add(AddDJYTenantParamInput input) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 更新租户参数类别表 /// /// [HttpPost("/DJYTenantParam/edit")] public async Task Update(UpdateDJYTenantParamInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } /// /// 删除租户参数类别表 /// /// [HttpPost("/DJYTenantParam/delete")] [SqlSugarUnitOfWork] public async Task Delete(long Id) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == Id); await _itemrep.DeleteAsync(m => m.ParaCode == entity.ParaCode); await _valuerep.DeleteAsync(m => m.ParaCode == entity.ParaCode); await _rep.DeleteAsync(entity); } /// /// 获取租户参数类别 /// /// [HttpGet("/DJYTenantParam/get")] public async Task> Get(string Type) { return await _rep.AsQueryable().Where(x => x.Type == Type).OrderBy(x => x.Sort).ToListAsync(); } /// /// 获取租户参数 /// /// [HttpGet("/DJYTenantParam/getParamItem")] public async Task> GetParamItem(string ParaCode) { return await _itemrep.AsQueryable().Where(x => x.ParaCode == ParaCode).OrderBy(x => x.Sort).ToListAsync(); } /// /// 增加租户参数 /// /// [HttpPost("/DJYTenantParam/addParamItem")] public async Task AddParamItem(DjyTenantParamItem input) { var entity = input.Adapt(); await _itemrep.InsertAsync(entity); } /// /// 更新租户参数 /// /// [HttpPost("/DJYTenantParam/editParamItem")] public async Task UpdateParamItem(DjyTenantParamItem input) { var entity = input.Adapt(); await _itemrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } } }