|
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -30,10 +31,10 @@ namespace Myshipping.Core.Service
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
_itemrep = itemrep;
|
|
|
|
_itemrep = itemrep;
|
|
|
|
_valuerep = valuerep;
|
|
|
|
_valuerep = valuerep;
|
|
|
|
_cache = cache;
|
|
|
|
_cache = cache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 类别
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 增加租户参数类别表
|
|
|
|
/// 增加租户参数类别表
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -41,6 +42,25 @@ namespace Myshipping.Core.Service
|
|
|
|
[HttpPost("/DJYTenantParam/add")]
|
|
|
|
[HttpPost("/DJYTenantParam/add")]
|
|
|
|
public async Task Add(AddDJYTenantParamInput input)
|
|
|
|
public async Task Add(AddDJYTenantParamInput input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param002);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.Type))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param008);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -52,6 +72,28 @@ namespace Myshipping.Core.Service
|
|
|
|
[HttpPost("/DJYTenantParam/edit")]
|
|
|
|
[HttpPost("/DJYTenantParam/edit")]
|
|
|
|
public async Task Update(UpdateDJYTenantParamInput input)
|
|
|
|
public async Task Update(UpdateDJYTenantParamInput input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (input.Id == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param002);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.Type))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param008);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Id != input.Id);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
var entity = input.Adapt<DjyTenantParam>();
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,21 +106,29 @@ namespace Myshipping.Core.Service
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
public async Task Delete(long Id)
|
|
|
|
public async Task Delete(long Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Id == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param000);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
await _itemrep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
|
|
|
|
await _itemrep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
|
|
|
|
await _valuerep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
|
|
|
|
await _valuerep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
|
|
|
|
await _rep.DeleteAsync(entity);
|
|
|
|
await _rep.DeleteAsync(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取租户参数类别
|
|
|
|
/// 获取租户参数类别
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("/DJYTenantParam/list")]
|
|
|
|
[HttpGet("/DJYTenantParam/list")]
|
|
|
|
public async Task<List<DjyTenantParam>> List(string Type)
|
|
|
|
public async Task<List<DjyTenantParam>> List(string Type, string ParaName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type),x => x.Type == Type).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaName), x => x.ParaName.Contains(ParaName)).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参数
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取租户参数
|
|
|
|
/// 获取租户参数
|
|
|
@ -100,6 +150,23 @@ namespace Myshipping.Core.Service
|
|
|
|
[HttpPost("/DJYTenantParam/addParamItem")]
|
|
|
|
[HttpPost("/DJYTenantParam/addParamItem")]
|
|
|
|
public async Task AddParamItem(DjyTenantParamItem input)
|
|
|
|
public async Task AddParamItem(DjyTenantParamItem input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param005);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param006);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = await _itemrep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.ItemCode == input.ItemCode);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
await _itemrep.InsertAsync(entity);
|
|
|
|
await _itemrep.InsertAsync(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -112,6 +179,27 @@ namespace Myshipping.Core.Service
|
|
|
|
[HttpPost("/DJYTenantParam/editParamItem")]
|
|
|
|
[HttpPost("/DJYTenantParam/editParamItem")]
|
|
|
|
public async Task UpdateParamItem(DjyTenantParamItem input)
|
|
|
|
public async Task UpdateParamItem(DjyTenantParamItem input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (input.Id == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param005);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param006);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = await _itemrep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.ItemCode == input.ItemCode && x.Id != input.Id);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
var entity = input.Adapt<DjyTenantParamItem>();
|
|
|
|
await _itemrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
await _itemrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
@ -125,30 +213,32 @@ namespace Myshipping.Core.Service
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
public async Task DeleteParamItem(long Id)
|
|
|
|
public async Task DeleteParamItem(long Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Id == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param000);
|
|
|
|
|
|
|
|
}
|
|
|
|
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
|
|
|
|
|
|
|
|
await _valuerep.DeleteAsync(m => m.ItemCode == entity.ItemCode && m.ParaCode == entity.ParaCode);
|
|
|
|
await _valuerep.DeleteAsync(m => m.ItemCode == entity.ItemCode && m.ParaCode == entity.ParaCode);
|
|
|
|
await _itemrep.DeleteAsync(entity);
|
|
|
|
await _itemrep.DeleteAsync(entity);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 值
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取参数
|
|
|
|
/// 获取参数
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("/DJYTenantParam/getParamValue")]
|
|
|
|
[HttpGet("/DJYTenantParam/getParamValue")]
|
|
|
|
public async Task<List<DjyTenantParamValue>> GetParamValue(long tenantId)
|
|
|
|
public async Task<List<DjyTenantParamValue>> GetParamValue(long tenantId, string paraCode = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tenantId==0) {
|
|
|
|
return await _valuerep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantId).WhereIF(paraCode != null, x => x.ParaCode == paraCode).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
tenantId = Convert.ToInt64(UserManager.TENANT_ID);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return await _valuerep.AsQueryable().Where(x => x.TenantId == tenantId).OrderBy(x => x.Sort).ToListAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 增加参数
|
|
|
|
/// 增加参数
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -157,6 +247,23 @@ namespace Myshipping.Core.Service
|
|
|
|
public async Task AddParamValue(DjyTenantParamValue input)
|
|
|
|
public async Task AddParamValue(DjyTenantParamValue input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param005);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input.TenantId == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param007);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
await _valuerep.InsertAsync(entity);
|
|
|
|
await _valuerep.InsertAsync(entity);
|
|
|
|
await CacheData();
|
|
|
|
await CacheData();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -170,27 +277,47 @@ namespace Myshipping.Core.Service
|
|
|
|
public async Task UpdateParamValue(DjyTenantParamValue input)
|
|
|
|
public async Task UpdateParamValue(DjyTenantParamValue input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
var entity = input.Adapt<DjyTenantParamValue>();
|
|
|
|
|
|
|
|
if (input.Id == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ParaCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.ItemCode))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param005);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input.TenantId == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param007);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId && x.Id != input.Id);
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(ErrorCode.Param004);
|
|
|
|
|
|
|
|
}
|
|
|
|
await _valuerep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
await _valuerep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
await CacheData();
|
|
|
|
await CacheData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 删除租户参数类别表
|
|
|
|
///删除参数
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("/DJYTenantParam/deleteParamValue")]
|
|
|
|
[HttpPost("/DJYTenantParam/deleteParamValue")]
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
public async Task DeleteParamValue(long Id)
|
|
|
|
public async Task DeleteParamValue(long Id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
await _valuerep.DeleteAsync(u => u.Id == Id);
|
|
|
|
await _valuerep.DeleteAsync(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public async Task CacheData()
|
|
|
|
public async Task CacheData()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
|
|
|
|
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await _cache.SetAllTenantParam(list);
|
|
|
|
await _cache.SetAllTenantParam(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|