委托单位权限控制相关

master
zhangxiaofeng 6 months ago
parent ced5a75d38
commit 7a03e6701e

@ -21,5 +21,10 @@ namespace Myshipping.Core.Const
/// 马士基API订舱
/// </summary>
public const long MenuMSKApi = 526643045195845;
/// <summary>
/// 往来单位维护
/// </summary>
public const long MenuDjyCustomer = 348241409437765;
}
}

@ -29,5 +29,11 @@
/// 删除订舱前是否先询问东胜
/// </summary>
public const string ASK_DS_BEFORE_DELETE_BOOKING_ORDER = "AskDsBeforeDeleteBookingOrder";
/// <summary>
/// 是否启用委托单位权限显示控制
/// </summary>
/// <remarks>开启此参数后,在部分接口查询数据时会根据当前登陆人的权限范围来决定返回哪些委托单位,如委托单位管理台账查询接口、委托单位下拉查询接口、舱位管理台账查询接口、舱位管理详情查询接口等</remarks>
public const string IS_ENABLE_CUSTOMER_AUTHORITY = "IS_ENABLE_CUSTOMER_AUTHORITY";
}
}

@ -867,6 +867,11 @@
马士基API订舱
</summary>
</member>
<member name="F:Myshipping.Core.Const.MenuConst.MenuDjyCustomer">
<summary>
往来单位维护
</summary>
</member>
<member name="T:Myshipping.Core.Const.TenantParamCode">
<summary>
租户参数Code常量
@ -897,6 +902,11 @@
删除订舱前是否先询问东胜
</summary>
</member>
<member name="F:Myshipping.Core.Const.TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY">
<summary>
是否启用委托单位权限显示控制
</summary>
</member>
<member name="P:Myshipping.Core.Entity.CodeCarrier.Code">
<summary>
代码
@ -11819,6 +11829,11 @@
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Core.Service.DjyCustomerService.BatchUpdate(Myshipping.Core.Service.BatchUpdateInput)">
<summary>
批量更新客户信息
</summary>
</member>
<member name="M:Myshipping.Core.Service.DjyCustomerService.RecCustomerUserSync(Myshipping.Core.Service.DjyCustomerFromCustomerDto)">
<summary>
接收客户端租户、用户的数据到运营端委托单位
@ -12630,6 +12645,56 @@
销售
</summary>
</member>
<member name="T:Myshipping.Core.Service.BatchUpdateInput">
<summary>
订舱客户批量修改参数
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.CustomnerIdList">
<summary>
客户主键列表
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.OPID">
<summary>
操作id
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.DOCID">
<summary>
单证id
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.OP">
<summary>
操作
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.DOC">
<summary>
单证
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.SALEID">
<summary>
销售ID
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.SALE">
<summary>
销售
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.CUSTSERVICEID">
<summary>
客服ID
</summary>
</member>
<member name="P:Myshipping.Core.Service.BatchUpdateInput.CUSTSERVICE">
<summary>
客服
</summary>
</member>
<member name="T:Myshipping.Core.Service.DjyCustomerOutput">
<summary>
客户输出参数

@ -18,6 +18,7 @@ using StackExchange.Profiling.Internal;
using Microsoft.AspNetCore.Authorization;
using static NPOI.HSSF.Util.HSSFColor;
using TinyPinyin;
using Myshipping.Core.Const;
namespace Myshipping.Core.Service
{
@ -30,17 +31,26 @@ namespace Myshipping.Core.Service
private readonly SqlSugarRepository<DjyCustomer> _rep;
private readonly SqlSugarRepository<DjyCustomerContact> _repContact;
private readonly SqlSugarRepository<DjyCustomerAddr> _repAddr;
private readonly ISysCacheService _cache;
private readonly ISysDataUserMenu _sysDataUserMenuService;
private readonly ILogger<DjyCustomerService> _logger;
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep, SqlSugarRepository<DjyCustomerContact> repContact, ILogger<DjyCustomerService> logger, SqlSugarRepository<DjyCustomerAddr> addrRepContact)
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep,
SqlSugarRepository<DjyCustomerContact> repContact,
ILogger<DjyCustomerService> logger,
SqlSugarRepository<DjyCustomerAddr> addrRepContact,
ISysCacheService cache,
ISysDataUserMenu sysDataUserMenuService)
{
_rep = rep;
_repContact = repContact;
_logger = logger;
_repAddr = addrRepContact;
_cache = cache;
_sysDataUserMenuService = sysDataUserMenuService;
}
/// <summary>
@ -51,7 +61,28 @@ namespace Myshipping.Core.Service
[HttpGet("/DjyCustomer/page")]
public async Task<dynamic> Page([FromQuery] QueryDjyCustomerInput input)
{
var entities = await _rep.AsQueryable().Filter(null, true)
var queryable = _rep.AsQueryable().Filter(null, true);
// 判断是否启用了委托单位查看控制权限
var tenantParamList = await _cache.GetAllTenantParam();
var isEnableCustomerAuthority = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID
&& x.ParaCode == TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY)?.ItemCode;
if (isEnableCustomerAuthority == "YES")
{
List<long> userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
if (userList?.Any() == true)
{
List<string> userListStr = userList.Select(x => x.ToString()).ToList();
queryable.Where(u => userList.Contains((long)u.CreatedUserId)
|| userListStr.Contains(u.OPID)
|| userListStr.Contains(u.SALEID)
|| userListStr.Contains(u.DOCID)
|| userListStr.Contains(u.CUSTSERVICEID));
}
}
var entities = await queryable
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeName), u => u.CodeName.Contains(input.CodeName.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.ShortName), u => u.ShortName.Contains(input.ShortName.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.FullName), u => u.FullName.Contains(input.FullName.Trim()))
@ -269,8 +300,27 @@ namespace Myshipping.Core.Service
[HttpGet("/DjyCustomer/Suggest")]
public async Task<dynamic> Suggest(string keyword, string type)
{
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
var entities = await _rep.AsQueryable().Filter(null, true)
var queryable = _rep.AsQueryable().Filter(null, true);
// 判断是否启用了委托单位查看控制权限
var tenantParamList = await _cache.GetAllTenantParam();
var isEnableCustomerAuthority = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID
&& x.ParaCode == TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY)?.ItemCode;
if (isEnableCustomerAuthority == "YES")
{
List<long> userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
if (userList?.Any() == true)
{
List<string> userListStr = userList.Select(x => x.ToString()).ToList();
queryable.Where(u => userList.Contains((long)u.CreatedUserId)
|| userListStr.Contains(u.OPID)
|| userListStr.Contains(u.SALEID)
|| userListStr.Contains(u.DOCID)
|| userListStr.Contains(u.CUSTSERVICEID));
}
}
var entities = await queryable
.Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!string.IsNullOrWhiteSpace(type), u => u.PropString.Contains(type))
.WhereIF(!string.IsNullOrWhiteSpace(keyword), u => u.CodeName.Contains(keyword) || u.ShortName.Contains(keyword))
@ -375,6 +425,43 @@ namespace Myshipping.Core.Service
return entityList.Select(x => new ValueTuple<string, string>(x.code, x.name)).ToList();
}
/// <summary>
/// 批量更新客户信息
/// </summary>
[HttpPost("/DjyCustomer/BatchUpdate")]
public async Task BatchUpdate(BatchUpdateInput input)
{
if (input.CustomnerIdList == null || input.CustomnerIdList.Count == 0)
{
throw Oops.Oh("客户列表为空");
}
var updateable = _rep.Context.Updateable<DjyCustomer>();
if (input.IsSetCUSTSERVICE)
{
updateable.SetColumns(x => x.CUSTSERVICE == input.CUSTSERVICE);
updateable.SetColumns(x => x.CUSTSERVICEID == input.CUSTSERVICEID);
}
if (input.IsSetSALE)
{
updateable.SetColumns(x => x.SALE == input.SALE);
updateable.SetColumns(x => x.SALEID == input.SALEID);
}
if (input.IsSetOP)
{
updateable.SetColumns(x => x.OP == input.OP);
updateable.SetColumns(x => x.OPID == input.OPID);
}
if (input.IsSetDOC)
{
updateable.SetColumns(x => x.DOC == input.DOC);
updateable.SetColumns(x => x.DOCID == input.DOCID);
}
if (input.IsSetCUSTSERVICE || input.IsSetSALE || input.IsSetOP || input.IsSetDOC)
{
await updateable.Where(x => input.CustomnerIdList.Contains(x.Id)).ExecuteCommandAsync();
}
}
#region 接收客户端租户、用户的数据到运营端委托单位
/// <summary>

@ -342,4 +342,53 @@ namespace Myshipping.Core.Service
public string SALE { get; set; }
}
/// <summary>
/// 订舱客户批量修改参数
/// </summary>
public class BatchUpdateInput
{
/// <summary>
/// 客户主键列表
/// </summary>
public List<long> CustomnerIdList { get; set; }
public bool IsSetOP { get; set; }
public bool IsSetDOC { get; set; }
public bool IsSetSALE { get; set; }
public bool IsSetCUSTSERVICE { get; set; }
/// <summary>
/// 操作id
/// </summary>
public string OPID { get; set; }
/// <summary>
/// 单证id
/// </summary>
public string DOCID { get; set; }
/// <summary>
/// 操作
/// </summary>
public string OP { get; set; }
/// <summary>
/// 单证
/// </summary>
public string DOC { get; set; }
/// <summary>
/// 销售ID
/// </summary>
public string SALEID { get; set; }
/// <summary>
/// 销售
/// </summary>
public string SALE { get; set; }
/// <summary>
/// 客服ID
/// </summary>
public string CUSTSERVICEID { get; set; }
/// <summary>
/// 客服
/// </summary>
public string CUSTSERVICE { get; set; }
}
}

Loading…
Cancel
Save