This commit is contained in:
ky_sunl
2021-04-23 10:38:52 +00:00
parent d60155d02f
commit c2ed43238b
25 changed files with 120 additions and 118 deletions

View File

@@ -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();
/// <summary>
/// 创建时间
@@ -66,6 +66,7 @@ namespace Dilon.Core
/// </summary>
[JsonIgnore, FakeDelete(true)]
[Comment("软删除标记")]
[Column("软删除标记", TypeName = "bit")]
public virtual bool IsDeleted { get; set; } = false;
}
}

View File

@@ -39,7 +39,8 @@ namespace Dilon.Core
/// 用户登录后默认展示此系统菜单
/// </summary>
[Comment("是否默认激活")]
public string Active { get; set; }
[Column("是否默认激活", TypeName = "bit")]
public bool Active { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除

View File

@@ -10,17 +10,17 @@ namespace Dilon.Core
/// <summary>
/// 授权菜单
/// </summary>
public List<long> GrantMenuIdList { get; set; } = new List<long>();
public List<string> GrantMenuIdList { get; set; } = new List<string>();
/// <summary>
/// 授权角色
/// </summary>
public virtual List<long> GrantRoleIdList { get; set; } = new List<long>();
public virtual List<string> GrantRoleIdList { get; set; } = new List<string>();
/// <summary>
/// 授权数据
/// </summary>
public virtual List<long> GrantOrgIdList { get; set; } = new List<long>();
public virtual List<string> GrantOrgIdList { get; set; } = new List<string>();
}
/// <summary>

View File

@@ -8,7 +8,7 @@ namespace Dilon.Core
string Name { get; }
bool SuperAdmin { get; }
SysUser User { get; }
long UserId { get; }
string UserId { get; }
Task<SysUser> CheckUserAsync(string userId, bool tracking = true);
Task<SysEmp> GetUserEmpInfo(string userId);

View File

@@ -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
};
}
}

View File

@@ -8,12 +8,12 @@ namespace Dilon.Core.Service
Task<bool> DelAsync(string key);
Task<bool> DelByPatternAsync(string key);
List<string> GetAllCacheKeys();
Task<List<long>> GetDataScope(long userId);
Task<List<AntDesignTreeNode>> GetMenu(long userId, string appCode);
Task<List<string>> GetPermission(long userId);
Task SetDataScope(long userId, List<long> dataScopes);
Task SetMenu(long userId, string appCode, List<AntDesignTreeNode> menus);
Task SetPermission(long userId, List<string> permissions);
Task<List<string>> GetDataScope(string userId);
Task<List<AntDesignTreeNode>> GetMenu(string userId, string appCode);
Task<List<string>> GetPermission(string userId);
Task SetDataScope(string userId, List<string> dataScopes);
Task SetMenu(string userId, string appCode, List<AntDesignTreeNode> menus);
Task SetPermission(string userId, List<string> permissions);
Task<bool> SetAsync(string key, object value);
Task<string> GetAsync(string key);
Task<T> GetAsync<T>(string key);

View File

@@ -5,10 +5,10 @@ namespace Dilon.Core.Service
{
public interface ISysEmpExtOrgPosService
{
Task AddOrUpdate(long empId, List<EmpExtOrgPosOutput> extIdList);
Task DeleteEmpExtInfoByUserId(long empId);
Task<List<EmpExtOrgPosOutput>> GetEmpExtOrgPosList(long empId);
Task<bool> HasExtOrgEmp(long orgId);
Task<bool> HasExtPosEmp(long posId);
Task AddOrUpdate(string empId, List<EmpExtOrgPosOutput> extIdList);
Task DeleteEmpExtInfoByUserId(string empId);
Task<List<EmpExtOrgPosOutput>> GetEmpExtOrgPosList(string empId);
Task<bool> HasExtOrgEmp(string orgId);
Task<bool> HasExtPosEmp(string posId);
}
}

View File

@@ -5,10 +5,10 @@ namespace Dilon.Core.Service
public interface ISysEmpService
{
Task AddOrUpdate(EmpOutput2 sysEmpParam);
Task DeleteEmpInfoByUserId(long empId);
Task<EmpOutput> GetEmpInfo(long empId);
Task<long> GetEmpOrgId(long empId);
Task<bool> HasOrgEmp(long orgId);
Task UpdateEmpOrgInfo(long orgId, string orgName);
Task DeleteEmpInfoByUserId(string empId);
Task<EmpOutput> GetEmpInfo(string empId);
Task<string> GetEmpOrgId(string empId);
Task<bool> HasOrgEmp(string orgId);
Task UpdateEmpOrgInfo(string orgId, string orgName);
}
}

View File

@@ -11,12 +11,12 @@ namespace Dilon.Core.Service
/// <summary>
/// Id
/// </summary>
public long Id { get; set; }
public string Id { get; set; }
/// <summary>
/// 父Id
/// </summary>
public long ParentId { get; set; }
public string ParentId { get; set; }
/// <summary>
/// 名称
@@ -43,12 +43,12 @@ namespace Dilon.Core.Service
/// </summary>
public long Pid { get; set; }
public long GetId()
public string GetId()
{
return Id;
}
public long GetPid()
public string GetPid()
{
return ParentId;
}

View File

@@ -8,12 +8,12 @@ namespace Dilon.Core.Service
{
Task AddOrg(AddOrgInput input);
Task DeleteOrg(DeleteOrgInput input);
Task<List<long>> GetDataScopeListByDataScopeType(int dataScopeType, long orgId);
Task<List<string>> GetDataScopeListByDataScopeType(int dataScopeType, string orgId);
Task<SysOrg> GetOrg([FromQuery] QueryOrgInput input);
Task<List<OrgOutput>> GetOrgList([FromQuery] OrgInput input);
Task<dynamic> GetOrgTree([FromQuery] OrgInput input);
Task<dynamic> QueryOrgPageList([FromQuery] PageOrgInput input);
Task UpdateOrg(UpdateOrgInput input);
Task<List<long>> GetUserDataScopeIdList();
Task<List<string>> GetUserDataScopeIdList();
}
}

View File

@@ -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<OrgOutput>())
@@ -72,9 +72,9 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="dataScopes"></param>
/// <returns></returns>
private List<long> GetDataScopeList(List<long> dataScopes)
private List<string> GetDataScopeList(List<string> dataScopes)
{
var dataScopeList = new List<long>();
var dataScopeList = new List<string>();
// 如果是超级管理员则获取所有组织机构,否则只获取其数据范围的机构数据
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<List<OrgOutput>>();
@@ -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
/// <returns></returns>
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<SysOrg> 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);
}
/// <summary>
@@ -266,7 +266,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private async Task<List<long>> GetChildIdListWithSelfById(long id)
private async Task<List<string>> 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<dynamic> GetOrgTree([FromQuery] OrgInput input)
{
var dataScopeList = new List<long>();
var dataScopeList = new List<string>();
if (!_userManager.SuperAdmin)
{
var dataScopes = await GetUserDataScopeIdList();
@@ -311,10 +311,10 @@ namespace Dilon.Core.Service
/// <param name="orgId"></param>
/// <returns></returns>
[NonAction]
public async Task<List<long>> GetDataScopeListByDataScopeType(int dataScopeType, long orgId)
public async Task<List<string>> GetDataScopeListByDataScopeType(int dataScopeType, string orgId)
{
var orgIdList = new List<long>();
if (orgId < 0)
var orgIdList = new List<string>();
if (string.IsNullOrEmpty(orgId))
return orgIdList;
// 如果是范围类型是全部数据则获取当前所有的组织架构Id
@@ -340,7 +340,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <returns></returns>
[NonAction]
public async Task<List<long>> GetUserDataScopeIdList()
public async Task<List<string>> GetUserDataScopeIdList()
{
return await App.GetService<ISysUserService>().GetUserDataScopeIdList();
}

View File

@@ -54,7 +54,7 @@ namespace Dilon.Core.Service
/// 角色Id
/// </summary>
[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
/// </summary>
[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
/// </summary>
[Required(ErrorMessageResourceName = "角色Id不能为空")]
public long Id { get; set; }
public string Id { get; set; }
}
public class GrantRoleDataInput : GrantRoleMenuInput

View File

@@ -5,9 +5,9 @@ namespace Dilon.Core.Service
{
public interface ISysRoleDataScopeService
{
Task DeleteRoleDataScopeListByOrgIdList(List<long> orgIdList);
Task DeleteRoleDataScopeListByRoleId(long roleId);
Task<List<long>> GetRoleDataScopeIdList(List<long> roleIdList);
Task DeleteRoleDataScopeListByOrgIdList(List<string> orgIdList);
Task DeleteRoleDataScopeListByRoleId(string roleId);
Task<List<string>> GetRoleDataScopeIdList(List<string> roleIdList);
Task GrantDataScope(GrantRoleDataInput input);
}
}

View File

@@ -5,9 +5,9 @@ namespace Dilon.Core.Service
{
public interface ISysRoleMenuService
{
Task DeleteRoleMenuListByMenuIdList(List<long> menuIdList);
Task DeleteRoleMenuListByRoleId(long roleId);
Task<List<long>> GetRoleMenuIdList(List<long> roleIdList);
Task DeleteRoleMenuListByMenuIdList(List<string> menuIdList);
Task DeleteRoleMenuListByRoleId(string roleId);
Task<List<string>> GetRoleMenuIdList(List<string> roleIdList);
Task GrantMenu(GrantRoleMenuInput input);
}
}

View File

@@ -8,16 +8,16 @@ namespace Dilon.Core.Service
{
Task AddRole(AddRoleInput input);
Task DeleteRole(DeleteRoleInput input);
Task<string> GetNameByRoleId(long roleId);
Task<string> GetNameByRoleId(string roleId);
Task<dynamic> GetRoleDropDown();
Task<SysRole> GetRoleInfo([FromQuery] QueryRoleInput input);
Task<dynamic> GetRoleList([FromQuery] RoleInput input);
Task<List<long>> GetUserDataScopeIdList(List<long> roleIdList, long orgId);
Task<List<RoleOutput>> GetUserRoleList(long userId);
Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId);
Task<List<RoleOutput>> GetUserRoleList(string userId);
Task GrantData(GrantRoleDataInput input);
Task GrantMenu(GrantRoleMenuInput input);
Task<List<long>> OwnData([FromQuery] QueryRoleInput input);
Task<List<long>> OwnMenu([FromQuery] QueryRoleInput input);
Task<List<string>> OwnData([FromQuery] QueryRoleInput input);
Task<List<string>> OwnMenu([FromQuery] QueryRoleInput input);
Task<dynamic> QueryRolePageList([FromQuery] RoleInput input);
Task UpdateRole(UpdateRoleInput input);
}

View File

@@ -49,7 +49,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="roleIdList"></param>
/// <returns></returns>
public async Task<List<long>> GetRoleDataScopeIdList(List<long> roleIdList)
public async Task<List<string>> GetRoleDataScopeIdList(List<string> roleIdList)
{
return await _sysRoleDataScopeRep.DetachedEntities
.Where(u => roleIdList.Contains(u.SysRoleId))
@@ -61,7 +61,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="orgIdList"></param>
/// <returns></returns>
public async Task DeleteRoleDataScopeListByOrgIdList(List<long> orgIdList)
public async Task DeleteRoleDataScopeListByOrgIdList(List<string> orgIdList)
{
var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => orgIdList.Contains(u.SysOrgId)).ToListAsync();
dataScopes.ForEach(u =>
@@ -75,7 +75,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
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 =>

View File

@@ -27,7 +27,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="roleIdList"></param>
/// <returns></returns>
public async Task<List<long>> GetRoleMenuIdList(List<long> roleIdList)
public async Task<List<string>> GetRoleMenuIdList(List<string> roleIdList)
{
return await _sysRoleMenuRep.DetachedEntities
.Where(u => roleIdList.Contains(u.SysRoleId))
@@ -67,7 +67,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="menuIdList"></param>
/// <returns></returns>
public async Task DeleteRoleMenuListByMenuIdList(List<long> menuIdList)
public async Task DeleteRoleMenuListByMenuIdList(List<string> menuIdList)
{
var roleMenus = await _sysRoleMenuRep.DetachedEntities.Where(u => menuIdList.Contains(u.SysMenuId)).ToListAsync();
roleMenus.ForEach(u =>
@@ -81,7 +81,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
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 =>

View File

@@ -47,7 +47,7 @@ namespace Dilon.Core.Service
/// <param name="userId"></param>
/// <returns></returns>
[NonAction]
public async Task<List<RoleOutput>> GetUserRoleList(long userId)
public async Task<List<RoleOutput>> 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<long>();
: new List<string>();
return await _sysRoleRep.DetachedEntities
.Where(roles.Count > 0, u => roles.Contains(u.Id))
@@ -239,12 +239,12 @@ namespace Dilon.Core.Service
/// <param name="orgId"></param>
/// <returns></returns>
[NonAction]
public async Task<List<long>> GetUserDataScopeIdList(List<long> roleIdList, long orgId)
public async Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId)
{
// 定义角色中最大数据范围的类型目前按最大范围策略来如果你同时拥有ALL和SELF的权限最后按ALL返回
int strongerDataScopeType = (int)DataScopeType.SELF;
var customDataScopeRoleIdList = new List<long>();
var customDataScopeRoleIdList = new List<string>();
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
/// <param name="roleId"></param>
/// <returns></returns>
[NonAction]
public async Task<string> GetNameByRoleId(long roleId)
public async Task<string> GetNameByRoleId(string roleId)
{
var role = await _sysRoleRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == roleId);
if (role == null)
@@ -286,9 +286,9 @@ namespace Dilon.Core.Service
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/sysRole/ownMenu")]
public async Task<List<long>> OwnMenu([FromQuery] QueryRoleInput input)
public async Task<List<string>> OwnMenu([FromQuery] QueryRoleInput input)
{
return await _sysRoleMenuService.GetRoleMenuIdList(new List<long> { input.Id });
return await _sysRoleMenuService.GetRoleMenuIdList(new List<string> { input.Id });
}
/// <summary>
@@ -297,9 +297,9 @@ namespace Dilon.Core.Service
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/sysRole/ownData")]
public async Task<List<long>> OwnData([FromQuery] QueryRoleInput input)
public async Task<List<string>> OwnData([FromQuery] QueryRoleInput input)
{
return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List<long> { input.Id });
return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List<string> { input.Id });
}
}
}

View File

@@ -5,9 +5,9 @@ namespace Dilon.Core.Service
{
public interface ISysUserDataScopeService
{
Task DeleteUserDataScopeListByOrgIdList(List<long> orgIdList);
Task DeleteUserDataScopeListByUserId(long userId);
Task<List<long>> GetUserDataScopeIdList(long userId);
Task DeleteUserDataScopeListByOrgIdList(List<string> orgIdList);
Task DeleteUserDataScopeListByUserId(string userId);
Task<List<string>> GetUserDataScopeIdList(string userId);
Task GrantData(UpdateUserInput input);
}
}

View File

@@ -5,10 +5,10 @@ namespace Dilon.Core.Service
{
public interface ISysUserRoleService
{
Task DeleteUserRoleListByRoleId(long roleId);
Task DeleteUserRoleListByUserId(long userId);
Task<List<long>> GetUserRoleDataScopeIdList(long userId, long orgId);
Task<List<long>> GetUserRoleIdList(long userId);
Task DeleteUserRoleListByRoleId(string roleId);
Task DeleteUserRoleListByUserId(string userId);
Task<List<string>> GetUserRoleDataScopeIdList(string userId, string orgId);
Task<List<string>> GetUserRoleIdList(string userId);
Task GrantRole(UpdateUserInput input);
}
}

View File

@@ -12,8 +12,8 @@ namespace Dilon.Core.Service
Task ExportUser([FromQuery] UserInput input);
Task<dynamic> GetUser([FromQuery] QueryUserInput input);
Task<dynamic> GetUserById(string userId);
Task<List<long>> GetUserDataScopeIdList();
Task<List<long>> GetUserDataScopeIdList(long userId);
Task<List<string>> GetUserDataScopeIdList();
Task<List<string>> GetUserDataScopeIdList(string userId);
Task<dynamic> GetUserOwnData([FromQuery] QueryUserInput input);
Task<dynamic> GetUserOwnRole([FromQuery] QueryUserInput input);
Task<dynamic> GetUserSelector([FromQuery] UserInput input);

View File

@@ -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
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<List<long>> GetUserDataScopeIdList(long userId)
public async Task<List<string>> GetUserDataScopeIdList(string userId)
{
return await _sysUserDataScopeRep.DetachedEntities
.Where(u => u.SysUserId == userId)
@@ -61,7 +61,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="orgIdList"></param>
/// <returns></returns>
public async Task DeleteUserDataScopeListByOrgIdList(List<long> orgIdList)
public async Task DeleteUserDataScopeListByOrgIdList(List<string> orgIdList)
{
var dataScopes = await _sysUserDataScopeRep.Where(u => orgIdList.Contains(u.SysOrgId)).ToListAsync();
dataScopes.ForEach(u =>
@@ -75,7 +75,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
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 =>

View File

@@ -28,7 +28,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<List<long>> GetUserRoleIdList(long userId)
public async Task<List<string>> 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
/// <param name="userId"></param>
/// <param name="orgId"></param>
/// <returns></returns>
public async Task<List<long>> GetUserRoleDataScopeIdList(long userId, long orgId)
public async Task<List<string>> GetUserRoleDataScopeIdList(string userId, string orgId)
{
var roleIdList = await GetUserRoleIdList(userId);
@@ -79,7 +79,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
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
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
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 =>

View File

@@ -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<UserOutput>.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<SysUser>();
@@ -171,7 +171,7 @@ namespace Dilon.Core.Service
[HttpGet("/sysUser/detail")]
public async Task<dynamic> 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<UserOutput>();
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<dynamic> GetUserOwnRole([FromQuery] QueryUserInput input)
{
return await _sysUserRoleService.GetUserRoleIdList(long.Parse(input.Id));
return await _sysUserRoleService.GetUserRoleIdList(input.Id);
}
/// <summary>
@@ -268,7 +268,7 @@ namespace Dilon.Core.Service
[HttpGet("/sysUser/ownData")]
public async Task<dynamic> GetUserOwnData([FromQuery] QueryUserInput input)
{
return await _sysUserDataScopeService.GetUserDataScopeIdList(long.Parse(input.Id));
return await _sysUserDataScopeService.GetUserDataScopeIdList(input.Id);
}
/// <summary>
@@ -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
/// <param name="userId"></param>
/// <returns></returns>
[NonAction]
public async Task<List<long>> GetUserDataScopeIdList(long userId)
public async Task<List<string>> GetUserDataScopeIdList(string userId)
{
var dataScopes = await _sysCacheService.GetDataScope(userId); // 先从缓存里面读取
if (dataScopes == null || dataScopes.Count < 1)
@@ -391,7 +391,7 @@ namespace Dilon.Core.Service
/// </summary>
/// <returns></returns>
[NonAction]
public async Task<List<long>> GetUserDataScopeIdList()
public async Task<List<string>> 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);
}
}

View File

@@ -12,13 +12,13 @@ namespace Dilon.Core
/// 获取节点id
/// </summary>
/// <returns></returns>
long GetId();
string GetId();
/// <summary>
/// 获取节点父id
/// </summary>
/// <returns></returns>
long GetPid();
string GetPid();
/// <summary>
/// 设置Children
@@ -36,7 +36,7 @@ namespace Dilon.Core
/// <summary>
/// 顶级节点的父节点Id(默认0)
/// </summary>
private readonly long _rootParentId = 0L;
private readonly string _rootParentId = System.Guid.Empty.ToString().ToLower();
/// <summary>
/// 构造树节点