|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 租户参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings(Name = "DJYTenantParam", Order = 1)]
|
|
|
|
|
public class DjyTenantParamService : IDjyTenantParamService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<DjyTenantParam> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<DjyTenantParamItem> _itemrep;
|
|
|
|
|
private readonly SqlSugarRepository<DjyTenantParamValue> _valuerep;
|
|
|
|
|
private readonly ILogger<DjyTenantParam> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
public DjyTenantParamService(SqlSugarRepository<DjyTenantParam> rep, SqlSugarRepository<DjyTenantParamItem> itemrep, SqlSugarRepository<DjyTenantParamValue> valuerep, ISysCacheService cache, ILogger<DjyTenantParam> logger)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_itemrep = itemrep;
|
|
|
|
|
_valuerep = valuerep;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加租户参数类别表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/add")]
|
|
|
|
|
public async Task Add(AddDJYTenantParamInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新租户参数类别表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/edit")]
|
|
|
|
|
public async Task Update(UpdateDJYTenantParamInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除租户参数类别表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取租户参数类别
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DJYTenantParam/get")]
|
|
|
|
|
public async Task<List<DjyTenantParam>> Get(string Type)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.AsQueryable().Where(x => x.Type == Type).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取租户参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DJYTenantParam/getParamItem")]
|
|
|
|
|
public async Task<List<DjyTenantParamItem>> GetParamItem(string ParaCode)
|
|
|
|
|
{
|
|
|
|
|
return await _itemrep.AsQueryable().Where(x => x.ParaCode == ParaCode).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加租户参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/addParamItem")]
|
|
|
|
|
public async Task AddParamItem(DjyTenantParamItem input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
|
await _itemrep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新租户参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/editParamItem")]
|
|
|
|
|
public async Task UpdateParamItem(DjyTenantParamItem input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
|
await _itemrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除租户参数类别表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/deleteParamItem")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task DeleteParamItem(long Id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
|
|
|
|
|
|
await _valuerep.DeleteAsync(m => m.ItemCode == entity.ItemCode && m.ParaCode == entity.ParaCode);
|
|
|
|
|
await _itemrep.DeleteAsync(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DJYTenantParam/getParamValue")]
|
|
|
|
|
public async Task<List<DjyTenantParamValue>> GetParamValue(long tenantId)
|
|
|
|
|
{
|
|
|
|
|
return await _valuerep.AsQueryable().Where(x => x.TenantId == tenantId).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/addParamValue")]
|
|
|
|
|
public async Task AddParamValue(DjyTenantParamValue input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
|
await _valuerep.InsertAsync(entity);
|
|
|
|
|
await CacheData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/editParamValue")]
|
|
|
|
|
public async Task UpdateParamValue(DjyTenantParamValue input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
|
await _valuerep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
await CacheData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除租户参数类别表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DJYTenantParam/deleteParamValue")]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task DeleteParamValue(long Id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
|
await _valuerep.DeleteAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task CacheData()
|
|
|
|
|
{
|
|
|
|
|
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
|
|
|
|
|
|
|
|
|
|
await _cache.SetAllTenantParam(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|