diff --git a/Api/Dilon.Core/Entity/DEntityBase.cs b/Api/Dilon.Core/Entity/DEntityBase.cs index 376d0d3..6d986f2 100644 --- a/Api/Dilon.Core/Entity/DEntityBase.cs +++ b/Api/Dilon.Core/Entity/DEntityBase.cs @@ -19,7 +19,7 @@ namespace Dilon.Core [DatabaseGenerated(DatabaseGeneratedOption.None)] [Comment("Id主键")] [Column("Id主键", TypeName = "varchar(36)")] - public virtual string Id { get; set; } + public virtual string Id { get; set; } = Guid.NewGuid().ToString(); /// /// 创建时间 @@ -66,6 +66,7 @@ namespace Dilon.Core /// [JsonIgnore, FakeDelete(true)] [Comment("软删除标记")] + [Column("软删除标记", TypeName = "bit")] public virtual bool IsDeleted { get; set; } = false; } } diff --git a/Api/Dilon.Core/Entity/SysApp.cs b/Api/Dilon.Core/Entity/SysApp.cs index d48d9f5..9bad1fe 100644 --- a/Api/Dilon.Core/Entity/SysApp.cs +++ b/Api/Dilon.Core/Entity/SysApp.cs @@ -39,7 +39,8 @@ namespace Dilon.Core /// 用户登录后默认展示此系统菜单 /// [Comment("是否默认激活")] - public string Active { get; set; } + [Column("是否默认激活", TypeName = "bit")] + public bool Active { get; set; } /// /// 状态(字典 0正常 1停用 2删除) diff --git a/Api/Dilon.Core/Extension/XnInputBase.cs b/Api/Dilon.Core/Extension/XnInputBase.cs index e77d291..89bda21 100644 --- a/Api/Dilon.Core/Extension/XnInputBase.cs +++ b/Api/Dilon.Core/Extension/XnInputBase.cs @@ -10,17 +10,17 @@ namespace Dilon.Core /// /// 授权菜单 /// - public List GrantMenuIdList { get; set; } = new List(); + public List GrantMenuIdList { get; set; } = new List(); /// /// 授权角色 /// - public virtual List GrantRoleIdList { get; set; } = new List(); + public virtual List GrantRoleIdList { get; set; } = new List(); /// /// 授权数据 /// - public virtual List GrantOrgIdList { get; set; } = new List(); + public virtual List GrantOrgIdList { get; set; } = new List(); } /// diff --git a/Api/Dilon.Core/Manager/IUserManager.cs b/Api/Dilon.Core/Manager/IUserManager.cs index 4d52c21..e28b71d 100644 --- a/Api/Dilon.Core/Manager/IUserManager.cs +++ b/Api/Dilon.Core/Manager/IUserManager.cs @@ -8,7 +8,7 @@ namespace Dilon.Core string Name { get; } bool SuperAdmin { get; } SysUser User { get; } - long UserId { get; } + string UserId { get; } Task CheckUserAsync(string userId, bool tracking = true); Task GetUserEmpInfo(string userId); diff --git a/Api/Dilon.Core/SeedData/SysAppSeedData.cs b/Api/Dilon.Core/SeedData/SysAppSeedData.cs index 9dd49ca..cbb4c40 100644 --- a/Api/Dilon.Core/SeedData/SysAppSeedData.cs +++ b/Api/Dilon.Core/SeedData/SysAppSeedData.cs @@ -20,10 +20,10 @@ namespace Dilon.Core { return new[] { - new SysApp{Id="8b2aeb5e-09a6-4afd-bcae-8ee8e5a1e6ec", Name="业务应用", Code="busapp", Active="N", Status=0, Sort=100 }, // 142307070922869 - new SysApp{Id="d781b8f1-0d08-48c8-b7a5-ed75ddfa676c", Name="系统管理", Code="system", Active="Y", Status=0, Sort=100 }, // 142307070898245 - new SysApp{Id="850ab86f-cd6a-4d49-b920-77dfa5d78813", Name="系统工具", Code="system_tool", Active="N", Status=0, Sort=100 }, // 142307070902341 - new SysApp{Id="05a32be5-82e8-423f-affa-e17232a63ee1", Name="高级功能", Code="advanced", Active="N", Status=0, Sort=100 } // 142307070922826 + new SysApp{Id="8b2aeb5e-09a6-4afd-bcae-8ee8e5a1e6ec", Name="业务应用", Code="busapp", Active=false, Status=0, Sort=100 }, // 142307070922869 + new SysApp{Id="d781b8f1-0d08-48c8-b7a5-ed75ddfa676c", Name="系统管理", Code="system", Active=true, Status=0, Sort=100 }, // 142307070898245 + new SysApp{Id="850ab86f-cd6a-4d49-b920-77dfa5d78813", Name="系统工具", Code="system_tool", Active=false, Status=0, Sort=100 }, // 142307070902341 + new SysApp{Id="05a32be5-82e8-423f-affa-e17232a63ee1", Name="高级功能", Code="advanced", Active=false, Status=0, Sort=100 } // 142307070922826 }; } } diff --git a/Api/Dilon.Core/Service/Cache/ISysCacheService.cs b/Api/Dilon.Core/Service/Cache/ISysCacheService.cs index a514d2b..5c69b0c 100644 --- a/Api/Dilon.Core/Service/Cache/ISysCacheService.cs +++ b/Api/Dilon.Core/Service/Cache/ISysCacheService.cs @@ -8,12 +8,12 @@ namespace Dilon.Core.Service Task DelAsync(string key); Task DelByPatternAsync(string key); List GetAllCacheKeys(); - Task> GetDataScope(long userId); - Task> GetMenu(long userId, string appCode); - Task> GetPermission(long userId); - Task SetDataScope(long userId, List dataScopes); - Task SetMenu(long userId, string appCode, List menus); - Task SetPermission(long userId, List permissions); + Task> GetDataScope(string userId); + Task> GetMenu(string userId, string appCode); + Task> GetPermission(string userId); + Task SetDataScope(string userId, List dataScopes); + Task SetMenu(string userId, string appCode, List menus); + Task SetPermission(string userId, List permissions); Task SetAsync(string key, object value); Task GetAsync(string key); Task GetAsync(string key); diff --git a/Api/Dilon.Core/Service/Emp/ISysEmpExtOrgPosService.cs b/Api/Dilon.Core/Service/Emp/ISysEmpExtOrgPosService.cs index d41b225..7d39598 100644 --- a/Api/Dilon.Core/Service/Emp/ISysEmpExtOrgPosService.cs +++ b/Api/Dilon.Core/Service/Emp/ISysEmpExtOrgPosService.cs @@ -5,10 +5,10 @@ namespace Dilon.Core.Service { public interface ISysEmpExtOrgPosService { - Task AddOrUpdate(long empId, List extIdList); - Task DeleteEmpExtInfoByUserId(long empId); - Task> GetEmpExtOrgPosList(long empId); - Task HasExtOrgEmp(long orgId); - Task HasExtPosEmp(long posId); + Task AddOrUpdate(string empId, List extIdList); + Task DeleteEmpExtInfoByUserId(string empId); + Task> GetEmpExtOrgPosList(string empId); + Task HasExtOrgEmp(string orgId); + Task HasExtPosEmp(string posId); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/Emp/ISysEmpService.cs b/Api/Dilon.Core/Service/Emp/ISysEmpService.cs index ebdbf91..21bb973 100644 --- a/Api/Dilon.Core/Service/Emp/ISysEmpService.cs +++ b/Api/Dilon.Core/Service/Emp/ISysEmpService.cs @@ -5,10 +5,10 @@ namespace Dilon.Core.Service public interface ISysEmpService { Task AddOrUpdate(EmpOutput2 sysEmpParam); - Task DeleteEmpInfoByUserId(long empId); - Task GetEmpInfo(long empId); - Task GetEmpOrgId(long empId); - Task HasOrgEmp(long orgId); - Task UpdateEmpOrgInfo(long orgId, string orgName); + Task DeleteEmpInfoByUserId(string empId); + Task GetEmpInfo(string empId); + Task GetEmpOrgId(string empId); + Task HasOrgEmp(string orgId); + Task UpdateEmpOrgInfo(string orgId, string orgName); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/Org/Dto/OrgTreeNode.cs b/Api/Dilon.Core/Service/Org/Dto/OrgTreeNode.cs index f51f628..9a2d363 100644 --- a/Api/Dilon.Core/Service/Org/Dto/OrgTreeNode.cs +++ b/Api/Dilon.Core/Service/Org/Dto/OrgTreeNode.cs @@ -11,12 +11,12 @@ namespace Dilon.Core.Service /// /// Id /// - public long Id { get; set; } + public string Id { get; set; } /// /// 父Id /// - public long ParentId { get; set; } + public string ParentId { get; set; } /// /// 名称 @@ -43,12 +43,12 @@ namespace Dilon.Core.Service /// public long Pid { get; set; } - public long GetId() + public string GetId() { return Id; } - public long GetPid() + public string GetPid() { return ParentId; } diff --git a/Api/Dilon.Core/Service/Org/ISysOrgService.cs b/Api/Dilon.Core/Service/Org/ISysOrgService.cs index 06c2527..6f06594 100644 --- a/Api/Dilon.Core/Service/Org/ISysOrgService.cs +++ b/Api/Dilon.Core/Service/Org/ISysOrgService.cs @@ -8,12 +8,12 @@ namespace Dilon.Core.Service { Task AddOrg(AddOrgInput input); Task DeleteOrg(DeleteOrgInput input); - Task> GetDataScopeListByDataScopeType(int dataScopeType, long orgId); + Task> GetDataScopeListByDataScopeType(int dataScopeType, string orgId); Task GetOrg([FromQuery] QueryOrgInput input); Task> GetOrgList([FromQuery] OrgInput input); Task GetOrgTree([FromQuery] OrgInput input); Task QueryOrgPageList([FromQuery] PageOrgInput input); Task UpdateOrg(UpdateOrgInput input); - Task> GetUserDataScopeIdList(); + Task> GetUserDataScopeIdList(); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/Org/SysOrgService.cs b/Api/Dilon.Core/Service/Org/SysOrgService.cs index 6b36293..a5bb1e4 100644 --- a/Api/Dilon.Core/Service/Org/SysOrgService.cs +++ b/Api/Dilon.Core/Service/Org/SysOrgService.cs @@ -57,9 +57,9 @@ namespace Dilon.Core.Service var pId = !string.IsNullOrEmpty(input.Pid?.Trim()); var orgs = await _sysOrgRep.DetachedEntities .Where((name, u => EF.Functions.Like(u.Name, $"%{input.Name.Trim()}%")), // 根据机构名称模糊查询 - (id, u => u.Id == long.Parse(input.Id.Trim())), // 根据机构id查询 + (id, u => u.Id == input.Id.Trim()), // 根据机构id查询 (pId, u => EF.Functions.Like(u.Pids, $"%[{input.Pid.Trim()}]%") - || u.Id == long.Parse(input.Pid.Trim()))) // 根据父机构id查询 + || u.Id == input.Pid.Trim())) // 根据父机构id查询 .Where(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) // 非管理员范围限制 .Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort) .Select(u => u.Adapt()) @@ -72,9 +72,9 @@ namespace Dilon.Core.Service /// /// /// - private List GetDataScopeList(List dataScopes) + private List GetDataScopeList(List dataScopes) { - var dataScopeList = new List(); + var dataScopeList = new List(); // 如果是超级管理员则获取所有组织机构,否则只获取其数据范围的机构数据 if (!_userManager.SuperAdmin) { @@ -86,7 +86,7 @@ namespace Dilon.Core.Service { var sysOrg = _sysOrgRep.DetachedEntities.FirstOrDefault(c => c.Id == u); var parentAndChildIdListWithSelf = sysOrg.Pids.TrimEnd(',').Replace("[", "").Replace("]", "") - .Split(",").Select(u => long.Parse(u)).ToList(); + .Split(",").ToList(); dataScopeList.AddRange(parentAndChildIdListWithSelf); }); } @@ -105,7 +105,7 @@ namespace Dilon.Core.Service var pId = !string.IsNullOrEmpty(input.Pid?.Trim()); var orgs = await _sysOrgRep.DetachedEntities - .Where(pId, u => u.Pid == long.Parse(input.Pid)) + .Where(pId, u => u.Pid == input.Pid) .Where(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) .Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort).ToListAsync(); return orgs.Adapt>(); @@ -130,7 +130,7 @@ namespace Dilon.Core.Service { // 新增组织机构的父机构不在自己的数据范围内 var dataScopes = await GetUserDataScopeIdList(); - if (dataScopes.Count < 1 || !dataScopes.Contains(long.Parse(input.Pid))) + if (dataScopes.Count < 1 || !dataScopes.Contains(input.Pid)) throw Oops.Oh(ErrorCode.D2003); } else @@ -149,7 +149,7 @@ namespace Dilon.Core.Service /// private async Task FillPids(SysOrg sysOrg) { - if (sysOrg.Pid == 0L) + if (sysOrg.Pid.Equals(System.Guid.Empty.ToString(), System.StringComparison.OrdinalIgnoreCase)) { sysOrg.Pids = "[" + 0 + "],"; } @@ -169,7 +169,7 @@ namespace Dilon.Core.Service [UnitOfWork] public async Task DeleteOrg(DeleteOrgInput input) { - var sysOrg = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var sysOrg = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id); // 检测数据范围能不能操作这个机构 var dataScopes = await GetUserDataScopeIdList(); @@ -212,18 +212,18 @@ namespace Dilon.Core.Service { if (input.Pid != "0" && !string.IsNullOrEmpty(input.Pid)) { - var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Pid)); + var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Pid); _ = org ?? throw Oops.Oh(ErrorCode.D2000); } if (input.Id == input.Pid) throw Oops.Oh(ErrorCode.D2001); // 如果是编辑,父id不能为自己的子节点 - var childIdListById = await GetChildIdListWithSelfById(long.Parse(input.Id)); - if (childIdListById.Contains(long.Parse(input.Pid))) + var childIdListById = await GetChildIdListWithSelfById(input.Id); + if (childIdListById.Contains(input.Pid)) throw Oops.Oh(ErrorCode.D2001); - var sysOrg = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var sysOrg = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id); // 检测数据范围能不能操作这个机构 var dataScopes = await GetUserDataScopeIdList(); @@ -258,7 +258,7 @@ namespace Dilon.Core.Service [HttpGet("/sysOrg/detail")] public async Task GetOrg([FromQuery] QueryOrgInput input) { - return await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + return await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id); } /// @@ -266,7 +266,7 @@ namespace Dilon.Core.Service /// /// /// - private async Task> GetChildIdListWithSelfById(long id) + private async Task> GetChildIdListWithSelfById(string id) { var childIdList = await _sysOrgRep.DetachedEntities .Where(u => EF.Functions.Like(u.Pids, $"%{id}%")) @@ -282,7 +282,7 @@ namespace Dilon.Core.Service [HttpGet("/sysOrg/tree")] public async Task GetOrgTree([FromQuery] OrgInput input) { - var dataScopeList = new List(); + var dataScopeList = new List(); if (!_userManager.SuperAdmin) { var dataScopes = await GetUserDataScopeIdList(); @@ -311,10 +311,10 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetDataScopeListByDataScopeType(int dataScopeType, long orgId) + public async Task> GetDataScopeListByDataScopeType(int dataScopeType, string orgId) { - var orgIdList = new List(); - if (orgId < 0) + var orgIdList = new List(); + if (string.IsNullOrEmpty(orgId)) return orgIdList; // 如果是范围类型是全部数据,则获取当前所有的组织架构Id @@ -340,7 +340,7 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetUserDataScopeIdList() + public async Task> GetUserDataScopeIdList() { return await App.GetService().GetUserDataScopeIdList(); } diff --git a/Api/Dilon.Core/Service/Role/Dto/RoleInput.cs b/Api/Dilon.Core/Service/Role/Dto/RoleInput.cs index 72bd702..f7f564b 100644 --- a/Api/Dilon.Core/Service/Role/Dto/RoleInput.cs +++ b/Api/Dilon.Core/Service/Role/Dto/RoleInput.cs @@ -54,7 +54,7 @@ namespace Dilon.Core.Service /// 角色Id /// [Required(ErrorMessageResourceName = "角色Id不能为空")] - public long Id { get; set; } + public string Id { get; set; } } public class UpdateRoleInput : AddRoleInput @@ -63,7 +63,7 @@ namespace Dilon.Core.Service /// 角色Id /// [Required(ErrorMessageResourceName = "角色Id不能为空")] - public long Id { get; set; } + public string Id { get; set; } } public class QueryRoleInput : DeleteRoleInput @@ -77,7 +77,7 @@ namespace Dilon.Core.Service /// 角色Id /// [Required(ErrorMessageResourceName = "角色Id不能为空")] - public long Id { get; set; } + public string Id { get; set; } } public class GrantRoleDataInput : GrantRoleMenuInput diff --git a/Api/Dilon.Core/Service/Role/ISysRoleDataScopeService.cs b/Api/Dilon.Core/Service/Role/ISysRoleDataScopeService.cs index de7a85d..85c597d 100644 --- a/Api/Dilon.Core/Service/Role/ISysRoleDataScopeService.cs +++ b/Api/Dilon.Core/Service/Role/ISysRoleDataScopeService.cs @@ -5,9 +5,9 @@ namespace Dilon.Core.Service { public interface ISysRoleDataScopeService { - Task DeleteRoleDataScopeListByOrgIdList(List orgIdList); - Task DeleteRoleDataScopeListByRoleId(long roleId); - Task> GetRoleDataScopeIdList(List roleIdList); + Task DeleteRoleDataScopeListByOrgIdList(List orgIdList); + Task DeleteRoleDataScopeListByRoleId(string roleId); + Task> GetRoleDataScopeIdList(List roleIdList); Task GrantDataScope(GrantRoleDataInput input); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/Role/ISysRoleMenuService.cs b/Api/Dilon.Core/Service/Role/ISysRoleMenuService.cs index bbd2151..2ac76ae 100644 --- a/Api/Dilon.Core/Service/Role/ISysRoleMenuService.cs +++ b/Api/Dilon.Core/Service/Role/ISysRoleMenuService.cs @@ -5,9 +5,9 @@ namespace Dilon.Core.Service { public interface ISysRoleMenuService { - Task DeleteRoleMenuListByMenuIdList(List menuIdList); - Task DeleteRoleMenuListByRoleId(long roleId); - Task> GetRoleMenuIdList(List roleIdList); + Task DeleteRoleMenuListByMenuIdList(List menuIdList); + Task DeleteRoleMenuListByRoleId(string roleId); + Task> GetRoleMenuIdList(List roleIdList); Task GrantMenu(GrantRoleMenuInput input); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/Role/ISysRoleService.cs b/Api/Dilon.Core/Service/Role/ISysRoleService.cs index cf10be2..6bda994 100644 --- a/Api/Dilon.Core/Service/Role/ISysRoleService.cs +++ b/Api/Dilon.Core/Service/Role/ISysRoleService.cs @@ -8,16 +8,16 @@ namespace Dilon.Core.Service { Task AddRole(AddRoleInput input); Task DeleteRole(DeleteRoleInput input); - Task GetNameByRoleId(long roleId); + Task GetNameByRoleId(string roleId); Task GetRoleDropDown(); Task GetRoleInfo([FromQuery] QueryRoleInput input); Task GetRoleList([FromQuery] RoleInput input); - Task> GetUserDataScopeIdList(List roleIdList, long orgId); - Task> GetUserRoleList(long userId); + Task> GetUserDataScopeIdList(List roleIdList, string orgId); + Task> GetUserRoleList(string userId); Task GrantData(GrantRoleDataInput input); Task GrantMenu(GrantRoleMenuInput input); - Task> OwnData([FromQuery] QueryRoleInput input); - Task> OwnMenu([FromQuery] QueryRoleInput input); + Task> OwnData([FromQuery] QueryRoleInput input); + Task> OwnMenu([FromQuery] QueryRoleInput input); Task QueryRolePageList([FromQuery] RoleInput input); Task UpdateRole(UpdateRoleInput input); } diff --git a/Api/Dilon.Core/Service/Role/SysRoleDataScopeService.cs b/Api/Dilon.Core/Service/Role/SysRoleDataScopeService.cs index 63ecd9f..beec55a 100644 --- a/Api/Dilon.Core/Service/Role/SysRoleDataScopeService.cs +++ b/Api/Dilon.Core/Service/Role/SysRoleDataScopeService.cs @@ -49,7 +49,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task> GetRoleDataScopeIdList(List roleIdList) + public async Task> GetRoleDataScopeIdList(List roleIdList) { return await _sysRoleDataScopeRep.DetachedEntities .Where(u => roleIdList.Contains(u.SysRoleId)) @@ -61,7 +61,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteRoleDataScopeListByOrgIdList(List orgIdList) + public async Task DeleteRoleDataScopeListByOrgIdList(List orgIdList) { var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => orgIdList.Contains(u.SysOrgId)).ToListAsync(); dataScopes.ForEach(u => @@ -75,7 +75,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteRoleDataScopeListByRoleId(long roleId) + public async Task DeleteRoleDataScopeListByRoleId(string roleId) { var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => u.SysRoleId == roleId).ToListAsync(); dataScopes.ForEach(u => diff --git a/Api/Dilon.Core/Service/Role/SysRoleMenuService.cs b/Api/Dilon.Core/Service/Role/SysRoleMenuService.cs index 640a1df..48dd3a4 100644 --- a/Api/Dilon.Core/Service/Role/SysRoleMenuService.cs +++ b/Api/Dilon.Core/Service/Role/SysRoleMenuService.cs @@ -27,7 +27,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task> GetRoleMenuIdList(List roleIdList) + public async Task> GetRoleMenuIdList(List roleIdList) { return await _sysRoleMenuRep.DetachedEntities .Where(u => roleIdList.Contains(u.SysRoleId)) @@ -67,7 +67,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteRoleMenuListByMenuIdList(List menuIdList) + public async Task DeleteRoleMenuListByMenuIdList(List menuIdList) { var roleMenus = await _sysRoleMenuRep.DetachedEntities.Where(u => menuIdList.Contains(u.SysMenuId)).ToListAsync(); roleMenus.ForEach(u => @@ -81,7 +81,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteRoleMenuListByRoleId(long roleId) + public async Task DeleteRoleMenuListByRoleId(string roleId) { var roleMenus = await _sysRoleMenuRep.DetachedEntities.Where(u => u.SysRoleId == roleId).ToListAsync(); roleMenus.ForEach(u => diff --git a/Api/Dilon.Core/Service/Role/SysRoleService.cs b/Api/Dilon.Core/Service/Role/SysRoleService.cs index 889483c..2c62578 100644 --- a/Api/Dilon.Core/Service/Role/SysRoleService.cs +++ b/Api/Dilon.Core/Service/Role/SysRoleService.cs @@ -47,7 +47,7 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetUserRoleList(long userId) + public async Task> GetUserRoleList(string userId) { return await _sysRoleRep.DetachedEntities.Join(_sysUserRoleRep.DetachedEntities, u => u.Id, e => e.SysRoleId, (u, e) => new { u, e }) .Where(x => x.e.SysUserId == userId) @@ -103,7 +103,7 @@ namespace Dilon.Core.Service // 如果不是超级管理员,则查询自己拥有的角色集合 var roles = _userManager.SuperAdmin ? await _sysUserRoleRep.Where(u => u.SysUserId == _userManager.UserId).Select(u => u.SysRoleId).ToListAsync() - : new List(); + : new List(); return await _sysRoleRep.DetachedEntities .Where(roles.Count > 0, u => roles.Contains(u.Id)) @@ -239,12 +239,12 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetUserDataScopeIdList(List roleIdList, long orgId) + public async Task> GetUserDataScopeIdList(List roleIdList, string orgId) { // 定义角色中最大数据范围的类型,目前按最大范围策略来,如果你同时拥有ALL和SELF的权限,最后按ALL返回 int strongerDataScopeType = (int)DataScopeType.SELF; - var customDataScopeRoleIdList = new List(); + var customDataScopeRoleIdList = new List(); if (roleIdList != null && roleIdList.Count > 0) { var roles = await _sysRoleRep.DetachedEntities.Where(u => roleIdList.Contains(u.Id)).ToListAsync(); @@ -272,7 +272,7 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task GetNameByRoleId(long roleId) + public async Task GetNameByRoleId(string roleId) { var role = await _sysRoleRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == roleId); if (role == null) @@ -286,9 +286,9 @@ namespace Dilon.Core.Service /// /// [HttpGet("/sysRole/ownMenu")] - public async Task> OwnMenu([FromQuery] QueryRoleInput input) + public async Task> OwnMenu([FromQuery] QueryRoleInput input) { - return await _sysRoleMenuService.GetRoleMenuIdList(new List { input.Id }); + return await _sysRoleMenuService.GetRoleMenuIdList(new List { input.Id }); } /// @@ -297,9 +297,9 @@ namespace Dilon.Core.Service /// /// [HttpGet("/sysRole/ownData")] - public async Task> OwnData([FromQuery] QueryRoleInput input) + public async Task> OwnData([FromQuery] QueryRoleInput input) { - return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List { input.Id }); + return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List { input.Id }); } } } diff --git a/Api/Dilon.Core/Service/User/ISysUserDataScopeService.cs b/Api/Dilon.Core/Service/User/ISysUserDataScopeService.cs index 815adf1..c8a9b0f 100644 --- a/Api/Dilon.Core/Service/User/ISysUserDataScopeService.cs +++ b/Api/Dilon.Core/Service/User/ISysUserDataScopeService.cs @@ -5,9 +5,9 @@ namespace Dilon.Core.Service { public interface ISysUserDataScopeService { - Task DeleteUserDataScopeListByOrgIdList(List orgIdList); - Task DeleteUserDataScopeListByUserId(long userId); - Task> GetUserDataScopeIdList(long userId); + Task DeleteUserDataScopeListByOrgIdList(List orgIdList); + Task DeleteUserDataScopeListByUserId(string userId); + Task> GetUserDataScopeIdList(string userId); Task GrantData(UpdateUserInput input); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/User/ISysUserRoleService.cs b/Api/Dilon.Core/Service/User/ISysUserRoleService.cs index db6c7cd..d54ee35 100644 --- a/Api/Dilon.Core/Service/User/ISysUserRoleService.cs +++ b/Api/Dilon.Core/Service/User/ISysUserRoleService.cs @@ -5,10 +5,10 @@ namespace Dilon.Core.Service { public interface ISysUserRoleService { - Task DeleteUserRoleListByRoleId(long roleId); - Task DeleteUserRoleListByUserId(long userId); - Task> GetUserRoleDataScopeIdList(long userId, long orgId); - Task> GetUserRoleIdList(long userId); + Task DeleteUserRoleListByRoleId(string roleId); + Task DeleteUserRoleListByUserId(string userId); + Task> GetUserRoleDataScopeIdList(string userId, string orgId); + Task> GetUserRoleIdList(string userId); Task GrantRole(UpdateUserInput input); } } \ No newline at end of file diff --git a/Api/Dilon.Core/Service/User/ISysUserService.cs b/Api/Dilon.Core/Service/User/ISysUserService.cs index 65c01e6..17688e9 100644 --- a/Api/Dilon.Core/Service/User/ISysUserService.cs +++ b/Api/Dilon.Core/Service/User/ISysUserService.cs @@ -12,8 +12,8 @@ namespace Dilon.Core.Service Task ExportUser([FromQuery] UserInput input); Task GetUser([FromQuery] QueryUserInput input); Task GetUserById(string userId); - Task> GetUserDataScopeIdList(); - Task> GetUserDataScopeIdList(long userId); + Task> GetUserDataScopeIdList(); + Task> GetUserDataScopeIdList(string userId); Task GetUserOwnData([FromQuery] QueryUserInput input); Task GetUserOwnRole([FromQuery] QueryUserInput input); Task GetUserSelector([FromQuery] UserInput input); diff --git a/Api/Dilon.Core/Service/User/SysUserDataScopeService.cs b/Api/Dilon.Core/Service/User/SysUserDataScopeService.cs index e32961e..e278fc6 100644 --- a/Api/Dilon.Core/Service/User/SysUserDataScopeService.cs +++ b/Api/Dilon.Core/Service/User/SysUserDataScopeService.cs @@ -28,7 +28,7 @@ namespace Dilon.Core.Service [UnitOfWork] public async Task GrantData(UpdateUserInput input) { - var dataScopes = await _sysUserDataScopeRep.Where(u => u.SysUserId == long.Parse(input.Id)).ToListAsync(); + var dataScopes = await _sysUserDataScopeRep.Where(u => u.SysUserId == input.Id).ToListAsync(); dataScopes.ForEach(u => { u.Delete(); @@ -38,7 +38,7 @@ namespace Dilon.Core.Service { new SysUserDataScope { - SysUserId = long.Parse(input.Id), + SysUserId = input.Id, SysOrgId = u }.Insert(); }); @@ -49,7 +49,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task> GetUserDataScopeIdList(long userId) + public async Task> GetUserDataScopeIdList(string userId) { return await _sysUserDataScopeRep.DetachedEntities .Where(u => u.SysUserId == userId) @@ -61,7 +61,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteUserDataScopeListByOrgIdList(List orgIdList) + public async Task DeleteUserDataScopeListByOrgIdList(List orgIdList) { var dataScopes = await _sysUserDataScopeRep.Where(u => orgIdList.Contains(u.SysOrgId)).ToListAsync(); dataScopes.ForEach(u => @@ -75,7 +75,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteUserDataScopeListByUserId(long userId) + public async Task DeleteUserDataScopeListByUserId(string userId) { var dataScopes = await _sysUserDataScopeRep.Where(u => u.SysUserId == userId).ToListAsync(); dataScopes.ForEach(u => diff --git a/Api/Dilon.Core/Service/User/SysUserRoleService.cs b/Api/Dilon.Core/Service/User/SysUserRoleService.cs index 11dba24..4245006 100644 --- a/Api/Dilon.Core/Service/User/SysUserRoleService.cs +++ b/Api/Dilon.Core/Service/User/SysUserRoleService.cs @@ -28,7 +28,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task> GetUserRoleIdList(long userId) + public async Task> GetUserRoleIdList(string userId) { return await _sysUserRoleRep.DetachedEntities.Where(u => u.SysUserId == userId).Select(u => u.SysRoleId).ToListAsync(); } @@ -41,7 +41,7 @@ namespace Dilon.Core.Service [UnitOfWork] public async Task GrantRole(UpdateUserInput input) { - var userRoles = await _sysUserRoleRep.Where(u => u.SysUserId == long.Parse(input.Id)).ToListAsync(); + var userRoles = await _sysUserRoleRep.Where(u => u.SysUserId == input.Id).ToListAsync(); userRoles.ForEach(u => { u.Delete(); @@ -51,7 +51,7 @@ namespace Dilon.Core.Service { new SysUserRole { - SysUserId = long.Parse(input.Id), + SysUserId = input.Id, SysRoleId = u }.Insert(); }); @@ -63,7 +63,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task> GetUserRoleDataScopeIdList(long userId, long orgId) + public async Task> GetUserRoleDataScopeIdList(string userId, string orgId) { var roleIdList = await GetUserRoleIdList(userId); @@ -79,7 +79,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteUserRoleListByRoleId(long roleId) + public async Task DeleteUserRoleListByRoleId(string roleId) { var userRoles = await _sysUserRoleRep.Where(u => u.SysRoleId == roleId).ToListAsync(); userRoles.ForEach(u => @@ -93,7 +93,7 @@ namespace Dilon.Core.Service /// /// /// - public async Task DeleteUserRoleListByUserId(long userId) + public async Task DeleteUserRoleListByUserId(string userId) { var userRoles = await _sysUserRoleRep.Where(u => u.SysUserId == userId).ToListAsync(); userRoles.ForEach(u => diff --git a/Api/Dilon.Core/Service/User/SysUserService.cs b/Api/Dilon.Core/Service/User/SysUserService.cs index bd5030c..b0ee997 100644 --- a/Api/Dilon.Core/Service/User/SysUserService.cs +++ b/Api/Dilon.Core/Service/User/SysUserService.cs @@ -64,7 +64,7 @@ namespace Dilon.Core.Service .Where(!string.IsNullOrEmpty(searchValue), x => (x.n.u.Account.Contains(input.SearchValue) || x.n.u.Name.Contains(input.SearchValue) || x.n.u.Phone.Contains(input.SearchValue))) - .Where(!string.IsNullOrEmpty(pid), x => (x.n.e.OrgId == long.Parse(pid) || + .Where(!string.IsNullOrEmpty(pid), x => (x.n.e.OrgId == pid || x.o.Pids.Contains($"[{pid.Trim()}]"))) .Where(input.SearchStatus >= 0, x => x.n.u.Status == input.SearchStatus) .Where(!superAdmin, x => x.n.u.AdminType != AdminType.SuperAdmin) @@ -79,7 +79,7 @@ namespace Dilon.Core.Service //await Task.WhenAll(emps); foreach (var user in users.Items) { - user.SysEmpInfo = await _sysEmpService.GetEmpInfo(long.Parse(user.Id)); + user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id); } return XnPageResult.PageResult(users); } @@ -120,7 +120,7 @@ namespace Dilon.Core.Service [UnitOfWork] public async Task DeleteUser(DeleteUserInput input) { - var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id); if (user.AdminType == AdminType.SuperAdmin) throw Oops.Oh(ErrorCode.D1014); @@ -153,7 +153,7 @@ namespace Dilon.Core.Service CheckDataScope(input); // 排除自己并且判断与其他是否相同 - var isExist = await _sysUserRep.AnyAsync(u => u.Account == input.Account && u.Id != long.Parse(input.Id), false); + var isExist = await _sysUserRep.AnyAsync(u => u.Account == input.Account && u.Id != input.Id, false); if (isExist) throw Oops.Oh(ErrorCode.D1003); var user = input.Adapt(); @@ -171,7 +171,7 @@ namespace Dilon.Core.Service [HttpGet("/sysUser/detail")] public async Task GetUser([FromQuery] QueryUserInput input) { - var user = await _sysUserRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id); var userDto = user.Adapt(); if (userDto != null) { @@ -188,7 +188,7 @@ namespace Dilon.Core.Service [HttpPost("/sysUser/changeStatus")] public async Task ChangeUserStatus(UpdateUserInput input) { - var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id); if (user.AdminType == AdminType.SuperAdmin) throw Oops.Oh(ErrorCode.D1015); @@ -243,7 +243,7 @@ namespace Dilon.Core.Service [HttpPost("/sysUser/updatePwd")] public async Task UpdateUserPwd(ChangePasswordUserInput input) { - var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id); if (MD5Encryption.Encrypt(input.Password) != user.Password) throw Oops.Oh(ErrorCode.D1004); user.Password = MD5Encryption.Encrypt(input.NewPassword); @@ -257,7 +257,7 @@ namespace Dilon.Core.Service [HttpGet("/sysUser/ownRole")] public async Task GetUserOwnRole([FromQuery] QueryUserInput input) { - return await _sysUserRoleService.GetUserRoleIdList(long.Parse(input.Id)); + return await _sysUserRoleService.GetUserRoleIdList(input.Id); } /// @@ -268,7 +268,7 @@ namespace Dilon.Core.Service [HttpGet("/sysUser/ownData")] public async Task GetUserOwnData([FromQuery] QueryUserInput input) { - return await _sysUserDataScopeService.GetUserDataScopeIdList(long.Parse(input.Id)); + return await _sysUserDataScopeService.GetUserDataScopeIdList(input.Id); } /// @@ -279,7 +279,7 @@ namespace Dilon.Core.Service [HttpPost("/sysUser/resetPwd")] public async Task ResetUserPwd(QueryUserInput input) { - var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id); user.Password = MD5Encryption.Encrypt(CommonConst.DEFAULT_PASSWORD); } @@ -291,7 +291,7 @@ namespace Dilon.Core.Service [HttpPost("/sysUser/updateAvatar")] public async Task UpdateAvatar(UpdateUserInput input) { - var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == long.Parse(input.Id)); + var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id); // 调用文件上传 //sysFileInfoService.assertFile(input.Avatar); user.Avatar = input.Avatar; @@ -366,7 +366,7 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetUserDataScopeIdList(long userId) + public async Task> GetUserDataScopeIdList(string userId) { var dataScopes = await _sysCacheService.GetDataScope(userId); // 先从缓存里面读取 if (dataScopes == null || dataScopes.Count < 1) @@ -391,7 +391,7 @@ namespace Dilon.Core.Service /// /// [NonAction] - public async Task> GetUserDataScopeIdList() + public async Task> GetUserDataScopeIdList() { var userId = _userManager.UserId; var dataScopes = await GetUserDataScopeIdList(userId); @@ -409,7 +409,7 @@ namespace Dilon.Core.Service if (!_userManager.SuperAdmin) { var dataScopes = await GetUserDataScopeIdList(_userManager.UserId); - if (dataScopes == null || (userParam.SysEmpParam.OrgId != null && !dataScopes.Contains(long.Parse(userParam.SysEmpParam.OrgId)))) + if (dataScopes == null || (userParam.SysEmpParam.OrgId != null && !dataScopes.Contains(userParam.SysEmpParam.OrgId))) throw Oops.Oh(ErrorCode.D1013); } } diff --git a/Api/Dilon.Core/Util/TreeBuildUtil.cs b/Api/Dilon.Core/Util/TreeBuildUtil.cs index 8e92994..30513f1 100644 --- a/Api/Dilon.Core/Util/TreeBuildUtil.cs +++ b/Api/Dilon.Core/Util/TreeBuildUtil.cs @@ -12,13 +12,13 @@ namespace Dilon.Core /// 获取节点id /// /// - long GetId(); + string GetId(); /// /// 获取节点父id /// /// - long GetPid(); + string GetPid(); /// /// 设置Children @@ -36,7 +36,7 @@ namespace Dilon.Core /// /// 顶级节点的父节点Id(默认0) /// - private readonly long _rootParentId = 0L; + private readonly string _rootParentId = System.Guid.Empty.ToString().ToLower(); /// /// 构造树节点