租户管理接口、修复审批重复问题、机构管理接口等

master
ZR20090193-陈敬勇 9 months ago
parent 68f0c3f333
commit 4a9c9dbe1e

File diff suppressed because it is too large Load Diff

@ -23,7 +23,11 @@ public static class MultiLanguageConst
/// </summary> /// </summary>
[Description("更新成功")] [Description("更新成功")]
public const string DataUpdateSuccess = "Data_Update_Success"; public const string DataUpdateSuccess = "Data_Update_Success";
/// <summary>
/// 更新失败
/// </summary>
[Description("更新失败")]
public const string DataUpdateFailed = "Data_Update_Failed";
/// <summary> /// <summary>
/// 导入成功 /// 导入成功
/// </summary> /// </summary>
@ -45,6 +49,9 @@ public static class MultiLanguageConst
[Description("角色唯一编码已存在")] [Description("角色唯一编码已存在")]
public const string RoleCodeExist = "RoleCode_Exist"; public const string RoleCodeExist = "RoleCode_Exist";
#endregion #endregion
[Description("机构名称已存在")]
public const string OrgNameExist = "OrgName_Exist";
/// <summary> /// <summary>
/// 权限模块不存在 /// 权限模块不存在
/// </summary> /// </summary>

@ -0,0 +1,86 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 企业用户管理模块
/// </summary>
public class TenantController : ApiController
{
private readonly ITenantService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public TenantController(ITenantService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 企业用户列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetTenantList")]
public DataResult<List<TenantRes>> GetTenantList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 获取企业用户信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetTenantInfo")]
public DataResult<TenantRes> GetTenantInfo([FromQuery] string id)
{
var res = _invokeService.GetTenantInfo(id);
return res;
}
/// <summary>
/// 获取租户权限
/// </summary>
/// <param name="id">租户Id</param>
/// <returns></returns>
[HttpGet]
[Route("GetTenantPermission")]
public DataResult<long[]> GetTenantPermission([FromQuery] string id)
{
var res = _invokeService.GetTenantPermission(id);
return res;
}
/// <summary>
/// 获取租户权限授权数
/// </summary>
/// <param name="id">租户Id</param>
/// <returns></returns>
[HttpGet]
[Route("GetPermissionAuthList")]
public DataResult<List<PermissionAuth>> GetPermissionAuthList([FromQuery] string id)
{
var res = _invokeService.GetPermissionAuthList(id);
return res;
}
/// <summary>
/// 租户权限模块授权
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("UpdateTenantPermission")]
public DataResult UpdateTenantPermission([FromBody] TenantPermissionReq req)
{
return _invokeService.UpdateTenantPermission(req);
}
}

@ -376,3 +376,31 @@
2024-02-18 17:52:10.0366 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config 2024-02-18 17:52:10.0366 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-18 17:52:10.0617 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-02-18 17:52:10.0617 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-18 17:52:10.1117 Info Configuration initialized. 2024-02-18 17:52:10.1117 Info Configuration initialized.
2024-02-19 08:55:43.3439 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 08:55:43.4604 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 08:55:43.4938 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 08:55:43.5590 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 08:55:43.6105 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-19 08:55:43.6326 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 08:55:43.6822 Info Configuration initialized.
2024-02-19 09:22:49.9888 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 09:22:50.0808 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 09:22:50.1006 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 09:22:50.1387 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 09:22:50.1630 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-19 09:22:50.1740 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 09:22:50.1931 Info Configuration initialized.
2024-02-19 14:09:20.3471 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 14:09:20.4959 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 14:09:20.5463 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 14:09:20.8314 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 14:09:20.9619 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-19 14:09:21.1321 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 14:09:21.1983 Info Configuration initialized.
2024-02-19 14:33:49.1222 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 14:33:49.1439 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 14:33:49.1635 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 14:33:49.1872 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 14:33:49.2154 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-02-19 14:33:49.2301 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 14:33:49.2610 Info Configuration initialized.

@ -56,7 +56,7 @@ public class FlowInstanceService : IFlowInstanceService
{ {
var info = db.Queryable<FlowInstance>().Where(x => x.Id == req.Id).First(); var info = db.Queryable<FlowInstance>().Where(x => x.Id == req.Id).First();
if (info.FlowStatus != FlowStatusEnum.Draft.ToEnumInt() || info.FlowStatus != FlowStatusEnum.Ready.ToEnumInt()) if(!(info.FlowStatus == FlowStatusEnum.Draft.ToEnumInt() || info.FlowStatus == FlowStatusEnum.Ready.ToEnumInt()))
{ {
return DataResult.Failed("只能修改【就绪】和【撤销】状态的流程",MultiLanguageConst.FlowEditOnlyReadyAndCancel); return DataResult.Failed("只能修改【就绪】和【撤销】状态的流程",MultiLanguageConst.FlowEditOnlyReadyAndCancel);
} }
@ -302,7 +302,6 @@ public class FlowInstanceService : IFlowInstanceService
if (instance.ActivityType == 0) //当前节点是会签节点 if (instance.ActivityType == 0) //当前节点是会签节点
{ {
//会签时的【当前节点】一直是会签开始节点 //会签时的【当前节点】一直是会签开始节点
wfruntime.MakeTagNode(wfruntime.CurrentNodeId, tag); //标记审核节点状态 wfruntime.MakeTagNode(wfruntime.CurrentNodeId, tag); //标记审核节点状态
string res = wfruntime.NodeConfluence(wfruntime.CurrentNodeId, tag); string res = wfruntime.NodeConfluence(wfruntime.CurrentNodeId, tag);
if (res == TagState.No.ToString("D")) if (res == TagState.No.ToString("D"))

@ -696,7 +696,7 @@ public class FlowRuntimeService
else if (!string.IsNullOrEmpty(res)) //会签结束,标记合流节点 else if (!string.IsNullOrEmpty(res)) //会签结束,标记合流节点
{ {
tag.Taged = (int)TagState.Ok; tag.Taged = (int)TagState.Ok;
MakeTagNode(nextNode.Id, tag); // MakeTagNode(nextNode.Id, tag);
NextNodeId = res; NextNodeId = res;
NextNodeType = GetNodeType(res); NextNodeType = GetNodeType(res);
} }

@ -0,0 +1,51 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 机构树信息
/// </summary>
public class OrgTree
{
public string Title { get; set; }
public long? Value { get; set; }
public long? ParentId { get; set; }
public List<OrgTree> Children { get; set; }
/// <summary>
/// 无参构造函数
/// </summary>
public OrgTree()
{
Children = new List<OrgTree>();
}
/// <summary>
/// 有参构造函数
/// </summary>
/// <param name="id">子id</param>
/// <param name="name">名称</param>
/// <param name="parentId">父id</param>
public OrgTree(long id, string name, long parentId)
{
this.Value = id;
this.Title = name;
this.ParentId = parentId;
Children = new List<OrgTree>();
}
/// <summary>
/// 有参构造函数
/// </summary>
/// <param name="id">子id</param>
/// <param name="name">名称</param>
/// <param name="parent">父节点</param>
public OrgTree(long id, string name, OrgTree parent)
{
this.Value = id;
this.Title = name;
this.ParentId = parent.Value;
Children = new List<OrgTree>();
}
}

@ -1,7 +1,7 @@
namespace DS.WMS.Core.System.Dtos; namespace DS.WMS.Core.System.Dtos;
/// <summary> /// <summary>
/// /// 角色权限树
/// </summary> /// </summary>
public class RolePermissionTreeViewModel public class RolePermissionTreeViewModel
{ {

@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户模块授权请求
/// </summary>
public class TenantPermissionReq
{
/// <summary>
///租户Id
/// </summary>
[Required(ErrorMessage = "租户Id不能为空")]
public long TenantId { get; set; }
/// <summary>
/// 授权Ids
/// </summary>
public List<long> PermissionIds { get; set; }
/// <summary>
/// 模块授权列表
/// </summary>
public List<PermissionAuth> PermissionAuthList { get; set; }
}

@ -0,0 +1,24 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户权限树
/// </summary>
public class TenantPermissionTreeViewModel
{
public List<TenantPermissionTree> TreeData { get; set; }
public string[] Ids { get; set; }
}
/// <summary>
///
/// </summary>
public class TenantPermissionTree
{
public string Title { get; set; }
public long Key { get; set; }
public List<TenantPermissionTree> Children { get; set; }
}

@ -0,0 +1,60 @@
using DS.Module.Core;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户返回实体
/// </summary>
public class TenantRes
{
/// <summary>
///
/// </summary>
public long Id { get; set; }
/// <summary>
/// 公司名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 拼音码
/// </summary>
public string PinYinCode { get; set; }= "";
/// <summary>
/// 公司地址
/// </summary>
public string Address { get; set; }= "";
/// <summary>
/// 租户管理员手机
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 公司电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 企业法人
/// </summary>
public string Chief { get; set; }
/// <summary>
/// 企业税号
/// </summary>
public string TaxNo { get; set; }
/// <summary>
/// 租户类型 0-普通租户 1-系统租户
/// </summary>
public int? TenantType { get; set; } = 0;
/// <summary>
/// 状态
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}

@ -29,5 +29,9 @@ public interface ISysOrgService
/// <returns></returns> /// <returns></returns>
DataResult<SysOrgRes> GetOrgInfo(string id); DataResult<SysOrgRes> GetOrgInfo(string id);
/// <summary>
/// 获取树型机构
/// </summary>
/// <returns></returns>
public DataResult<List<OrgTree>> GetOrgTree();
} }

@ -11,21 +11,32 @@ public interface ITenantService
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
DataResult<List<SysTenant>> GetListByPage(PageRequest request); DataResult<List<TenantRes>> GetListByPage(PageRequest request);
/// <summary> /// <summary>
/// 添加角色 /// 获取详情
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
DataResult EditTenant(TenantReq model); DataResult<TenantRes> GetTenantInfo(string id);
/// <summary> /// <summary>
/// 获取详情 /// 获取租户权限
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
DataResult<SysTenant> GetTenantInfo(string id); public DataResult<long[]> GetTenantPermission(string id);
/// <summary>
/// 获取租户权限授权数
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<List<PermissionAuth>> GetPermissionAuthList(string id);
/// <summary>
/// 租户权限模块授权
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult UpdateTenantPermission(TenantPermissionReq req);
} }

@ -52,14 +52,14 @@ public class SysOrgService:ISysOrgService
var isExist = db.Queryable<SysOrg>().Where(x => x.OrgName == req.OrgName).First(); var isExist = db.Queryable<SysOrg>().Where(x => x.OrgName == req.OrgName).First();
if (isExist != null) if (isExist != null)
{ {
return DataResult.Failed("机构名称已存在!"); return DataResult.Failed("机构名称已存在!",MultiLanguageConst.OrgNameExist);
} }
var data = req.Adapt<SysOrg>(); var data = req.Adapt<SysOrg>();
var entity = db.Insertable(data).ExecuteReturnEntity(); var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id); return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
} }
else else
{ {
@ -68,7 +68,7 @@ public class SysOrgService:ISysOrgService
info = req.Adapt(info); info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!"); return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
} }
} }
/// <summary> /// <summary>
@ -82,6 +82,58 @@ public class SysOrgService:ISysOrgService
.Where(a => a.Id == long.Parse(id)) .Where(a => a.Id == long.Parse(id))
.Select<SysOrgRes>() .Select<SysOrgRes>()
.First(); .First();
return DataResult<SysOrgRes>.Success(data); return DataResult<SysOrgRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
/// 获取树型机构
/// </summary>
/// <returns></returns>
public DataResult<List<OrgTree>> GetOrgTree()
{
var list = db.Queryable<SysOrg>().Select(a => new OrgTree
{
Title = a.OrgName,
Value = a.Id,
ParentId = a.ParentId
}).ToList();
var orgList = BulidTree(list);
return DataResult<List<OrgTree>>.Success("获取数据成功!", orgList);
}
/// <summary>
/// 双层循环
/// </summary>
/// <param name="treeNodes"></param>
/// <returns></returns>
public static List<OrgTree> BulidTree(List<OrgTree> treeNodes)
{
try
{
List<OrgTree> trees = new List<OrgTree>();
foreach (var treeNode in treeNodes)
{
if (0 == (treeNode.ParentId))
{
trees.Add(treeNode);
}
foreach (var it in treeNodes)
{
if (it.ParentId == treeNode.Value)
{
treeNode.Children.Add(it);
}
}
}
return trees;
}
catch (Exception ex)
{
throw ex;
}
} }
} }

@ -1,8 +1,10 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity; using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface; using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
@ -31,63 +33,137 @@ public class TenantService : ITenantService
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public DataResult<List<SysTenant>> GetListByPage(PageRequest request) public DataResult<List<TenantRes>> GetListByPage(PageRequest request)
{ {
//序列化查询条件 //序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysTenant>() var data = db.Queryable<SysTenant>()
.Where(whereList).ToQueryPage(request.PageCondition); .Where(x => x.TenantType != 1)
.Where(whereList)
.Select<TenantRes>().ToQueryPage(request.PageCondition);
return data; return data;
} }
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<TenantRes> GetTenantInfo(string id)
{
var data = db.Queryable<SysTenant>()
.Where(a => a.Id == long.Parse(id))
.Select<TenantRes>()
.First();
return DataResult<TenantRes>.Success(data);
}
/// <summary>
/// 获取租户权限
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<long[]> GetTenantPermission(string id)
{
var data = db.Queryable<SysPermissionTenant>().Filter(null, true).Where(x => x.TenantId == long.Parse(id))
.Select(x => x.PermissionId).ToArray();
return DataResult<long[]>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
/// <summary> /// <summary>
/// /// 租户权限模块授权
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
public DataResult EditTenant(TenantReq model) public DataResult UpdateTenantPermission(TenantPermissionReq req)
{ {
if (model.Id.IsNullOrEmpty()) try
{ {
var isExist = db.Queryable<SysTenant>().Where(x => x.TaxNo == model.TaxNo).First(); //开启事务
if (isExist != null) db.Ado.BeginTran();
var existPermissions = db.Queryable<SysPermissionTenant>().Filter(null, true)
.Where(x => x.TenantId == req.TenantId).Select(n => n.PermissionId).ToArray();
var tenant = db.Queryable<SysTenant>().First(x => x.Id == req.TenantId);
IEnumerable<long> delPermissions = existPermissions.AsQueryable().Except(req.PermissionIds);
if (delPermissions.Count() > 0)
{
var delPers = db.Queryable<SysPermissionTenant>().Filter(null, true).Where(x =>
x.TenantId == req.TenantId && delPermissions.Contains(x.PermissionId))
.ToList();
db.Deleteable(delPers).ExecuteCommand();
}
IEnumerable<long> addPermissions = req.PermissionIds.AsQueryable().Except(existPermissions);
if (addPermissions.Count() > 0)
{ {
return DataResult.Failed("租户唯一编码已存在!"); var addPers = db.Queryable<SysPermission>().Filter(null, true)
.Where(x => addPermissions.Contains(x.Id)).ToList();
var tenantPerList = new List<SysPermissionTenant>();
foreach (var item in addPers)
{
var tenantPer = item.Adapt<SysPermissionTenant>();
tenantPer.TenantId = req.TenantId;
tenantPer.PermissionId = item.Id;
tenantPerList.Add(tenantPer);
}
db.Insertable(tenantPerList).ExecuteCommand();
} }
var data = model.MapTo<TenantReq, SysTenant>();
db.Insertable(data).ExecuteCommand(); foreach (var item in req.PermissionAuthList)
{
var perAuth = db.Queryable<SysTenantPermissionAuth>().Filter(null, true)
.Where(x => x.TenantId == req.TenantId && x.PermissionId == item.PermissionId).First();
if (perAuth.IsNotNull())
{
if (perAuth.AuthNum != EncrypteHelper.EncryptData(item.AuthNum.ToString(), tenant.AppSecret))
{
perAuth.AuthNum = EncrypteHelper.EncryptData(item.AuthNum.ToString(), tenant.AppSecret);
db.Updateable(perAuth).ExecuteCommand();
}
}
else
{
var addPerAuth = new SysTenantPermissionAuth()
{
TenantId = tenant.Id,
PermissionId = item.PermissionId,
AuthNum = EncrypteHelper.EncryptData(item.AuthNum.ToString(), tenant.AppSecret)
};
db.Insertable(addPerAuth).ExecuteCommand();
}
}
return DataResult.Successed("添加成功!"); db.Ado.CommitTran();
return DataResult.Successed("租户权限模块授权成功!", MultiLanguageConst.DataUpdateSuccess);
} }
else catch (Exception ex)
{ {
var info = db.Queryable<SysTenant>().Where(x => x.Id == model.Id).First(); db.Ado.RollbackTran();
return DataResult.Failed("租户权限模块授权失败!" + ex, MultiLanguageConst.DataUpdateFailed);
info = model.MapTo<TenantReq, SysTenant>();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!");
} }
} }
/// <summary> public DataResult<List<PermissionAuth>> GetPermissionAuthList(string id)
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<SysTenant> GetTenantInfo(string id)
{ {
var data = db.Queryable<SysTenant>() var list = new List<PermissionAuth>();
.Where(a => a.Id ==long.Parse(id)) var tenant = db.Queryable<SysTenant>().First(x => x.Id == long.Parse(id));
.First();
return DataResult<SysTenant>.Success(data);
}
var perAuthList = db.Queryable<SysTenantPermissionAuth>().Filter(null, true)
.Where(x => x.TenantId == long.Parse(id)).ToList();
foreach (var item in perAuthList)
{
list.Add(new PermissionAuth()
{
PermissionId = item.PermissionId,
AuthNum = Int32.Parse(EncrypteHelper.DecryptData(item.AuthNum, tenant.AppSecret)) ,
});
}
return DataResult<List<PermissionAuth>>.Success("获取数据成功!", list, MultiLanguageConst.DataQuerySuccess);
}
} }

@ -59,4 +59,15 @@ public class OrgController : ApiController
var res = _invokeService.GetOrgInfo(id); var res = _invokeService.GetOrgInfo(id);
return res; return res;
} }
/// <summary>
/// 获取树型机构
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetOrgTree")]
public DataResult<List<OrgTree>> GetOrgTree()
{
var res = _invokeService.GetOrgTree();
return res;
}
} }

@ -124,3 +124,17 @@
2024-02-18 17:40:41.5357 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config 2024-02-18 17:40:41.5357 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-02-18 17:40:41.5712 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-02-18 17:40:41.5712 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-18 17:40:41.6435 Info Configuration initialized. 2024-02-18 17:40:41.6435 Info Configuration initialized.
2024-02-19 08:54:58.1582 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 08:54:58.2774 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 08:54:58.3029 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 08:54:58.3541 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 08:54:58.4343 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-02-19 08:54:58.4611 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 08:54:58.5029 Info Configuration initialized.
2024-02-19 14:09:24.0815 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-02-19 14:09:24.1286 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-02-19 14:09:24.1523 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-02-19 14:09:24.1825 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-02-19 14:09:24.2207 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-02-19 14:09:24.2517 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-19 14:09:24.3040 Info Configuration initialized.

@ -0,0 +1,148 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.System.Entity;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using Xunit;
namespace Ds.WMS.Test;
public class TreeTest
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
public TreeTest(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
}
[Fact]
public void TreeTest1()
{
TreeNode treeNode1 = new TreeNode("1", "山东", "0");
TreeNode treeNode2 = new TreeNode("2", "北京", "0");
TreeNode treeNode3 = new TreeNode("3", "历下区", treeNode1);
TreeNode treeNode4 = new TreeNode("4", "高新区", treeNode1);
TreeNode treeNode5 = new TreeNode("5", "历城区", treeNode1);
TreeNode treeNode6 = new TreeNode("6", "甸柳庄", treeNode3);
TreeNode treeNode7 = new TreeNode("7", "济南长途汽车站东站", treeNode6);
TreeNode treeNode8 = new TreeNode("8", "朝阳区", treeNode2);
TreeNode treeNode9 = new TreeNode("9", "海淀区", treeNode2);
TreeNode treeNode10 = new TreeNode("10", "金盏乡", treeNode8);
List<TreeNode> list = new List<TreeNode>();
list.Add(treeNode1);
list.Add(treeNode2);
list.Add(treeNode3);
list.Add(treeNode4);
list.Add(treeNode5);
list.Add(treeNode6);
list.Add(treeNode7);
list.Add(treeNode8);
list.Add(treeNode9);
list.Add(treeNode10);
List<TreeNode> trees = BulidTree(list);
Assert.True(true);
}
public class TreeNode
{
/// <summary>
/// 子id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 父id
/// </summary>
public string ParentId { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 子节点
/// </summary>
public List<TreeNode> Children { get; set; }
/// <summary>
/// 无参构造函数
/// </summary>
public TreeNode()
{
Children = new List<TreeNode>();
}
/// <summary>
/// 有参构造函数
/// </summary>
/// <param name="id">子id</param>
/// <param name="name">名称</param>
/// <param name="parentId">父id</param>
public TreeNode(string id, string name, string parentId)
{
this.Id = id;
this.Name = name;
this.ParentId = parentId;
Children = new List<TreeNode>();
}
/// <summary>
/// 有参构造函数
/// </summary>
/// <param name="id">子id</param>
/// <param name="name">名称</param>
/// <param name="parent">父节点</param>
public TreeNode(string id, string name, TreeNode parent)
{
this.Id = id;
this.Name = name;
this.ParentId = parent.Id;
Children = new List<TreeNode>();
}
}
/// <summary>
/// 双层循环
/// </summary>
/// <param name="treeNodes"></param>
/// <returns></returns>
public static List<TreeNode> BulidTree(List<TreeNode> treeNodes)
{
try
{
List<TreeNode> trees = new List<TreeNode>();
foreach (var treeNode in treeNodes)
{
if ("0" == (treeNode.ParentId))
{
trees.Add(treeNode);
}
foreach (var it in treeNodes)
{
if (it.ParentId == treeNode.Id)
{
treeNode.Children.Add(it);
}
}
}
return trees;
}
catch (Exception ex)
{
throw ex;
}
}
}
Loading…
Cancel
Save