v3.4.6
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Const;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Handlers;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -453,7 +454,7 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans
|
||||
_authorizeRepository.AsSugarClient().Ado.RollbackTran();
|
||||
}
|
||||
|
||||
if(input.objectId.Any()) await ForcedOffline(input.objectId); // 编辑角色权限退出角色的登录用户
|
||||
if (input.objectId.Any() && !input.itemType.Equals("portal")) await ForcedOffline(input.objectId); // 编辑角色权限退出角色的登录用户
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1083,7 +1084,7 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans
|
||||
/// <returns></returns>
|
||||
private async Task<bool> DelUserInfo(string tenantId, string userId)
|
||||
{
|
||||
var cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, userId);
|
||||
var cacheKey = string.Format("{0}:{1}:{2}", tenantId, CommonConst.CACHEKEYUSER, userId);
|
||||
return await _cacheManager.DelAsync(cacheKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,13 +172,16 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
||||
var pItems = treeList.Select(x => x.organizeIds.FirstOrDefault()).Distinct().ToList();
|
||||
pItems.ForEach(item =>
|
||||
{
|
||||
var addItem = orgTree.Find(x => x.Id.Equals(item)).Adapt<DepartmentSelectorOutput>();
|
||||
if (addItem.type != null && addItem.type.Equals("company")) addItem.icon = "icon-ym icon-ym-tree-organization3";
|
||||
addItem.fullName = orgTree.FirstOrDefault(x => x.Id.Equals(addItem.id))?.Description;
|
||||
addItem.organize = addItem.fullName;
|
||||
addItem.organizeIds = addItem.organizeIdTree.Split(",").ToList();
|
||||
addItem.disabled = true;
|
||||
if (!treeList.Any(x => x.id.Equals(addItem.id))) treeList.Add(addItem);
|
||||
if (treeList.Select(x => x.id).Contains(item))
|
||||
{
|
||||
var addItem = orgTree.Find(x => x.Id.Equals(item)).Adapt<DepartmentSelectorOutput>();
|
||||
if (addItem.type != null && addItem.type.Equals("company")) addItem.icon = "icon-ym icon-ym-tree-organization3";
|
||||
addItem.fullName = orgTree.FirstOrDefault(x => x.Id.Equals(addItem.id))?.Description;
|
||||
addItem.organize = addItem.fullName;
|
||||
addItem.organizeIds = addItem.organizeIdTree.Split(",").ToList();
|
||||
addItem.disabled = true;
|
||||
if (!treeList.Any(x => x.id.Equals(addItem.id))) treeList.Add(addItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
@@ -86,10 +87,10 @@ public class OrganizeAdministratorService : IOrganizeAdministratorService, IDyna
|
||||
var userIdList = await _repository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => x.ObjectType.Equals("Organize") && orgIds.Contains(x.ObjectId)).Select(x => x.UserId).ToListAsync();
|
||||
var organizeAdmin = await _repository.AsSugarClient().Queryable<OrganizeAdministratorEntity>().Where(x => !SqlFunc.ToString(x.UserId).Equals(_userManager.UserId))
|
||||
.WhereIF(!_userManager.IsAdministrator, x => orgIds.Contains(x.OrganizeId) && userIdList.Contains(x.UserId))
|
||||
.Select(x => x.UserId).ToListAsync();
|
||||
.Select(x => new { x.UserId, x.CreatorTime }).ToListAsync();
|
||||
|
||||
var data = await _repository.AsSugarClient().Queryable<UserEntity>()
|
||||
.Where(x => organizeAdmin.Contains(x.Id) && x.DeleteMark == null)
|
||||
.Where(x => organizeAdmin.Select(xx => xx.UserId).Contains(x.Id) && x.DeleteMark == null)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), x => x.Account.Contains(input.keyword) || x.RealName.Contains(input.keyword))
|
||||
.Select(x => new OrganizeAdministratorListOutput()
|
||||
{
|
||||
@@ -109,6 +110,7 @@ public class OrganizeAdministratorService : IOrganizeAdministratorService, IDyna
|
||||
// 获取用户组织集合
|
||||
List<string>? roleOrgList = orgUserIdAll.Where(x => x.UserId == item.id).Select(x => x.ObjectId).ToList();
|
||||
item.organizeId = string.Join(" , ", orgTreeNameList.Where(x => roleOrgList.Contains(x.Id)).Select(x => x.Description));
|
||||
item.creatorTime = organizeAdmin.Find(x => x.UserId.Equals(item.id)).CreatorTime;
|
||||
}
|
||||
|
||||
return PageResult<OrganizeAdministratorListOutput>.SqlSugarPageResult(data);
|
||||
|
||||
@@ -11,6 +11,7 @@ using JNPF.JsonSerialization;
|
||||
using JNPF.LinqBuilder;
|
||||
using JNPF.Systems.Entitys.Dto.Organize;
|
||||
using JNPF.Systems.Entitys.Dto.SysConfig;
|
||||
using JNPF.Systems.Entitys.Dto.User;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
@@ -215,13 +216,16 @@ public class OrganizeService : IOrganizeService, IDynamicApiController, ITransie
|
||||
var pItems = treeList.Select(x => x.organizeIds.FirstOrDefault()).Distinct().ToList();
|
||||
pItems.ForEach(item =>
|
||||
{
|
||||
var addItem = orgTree.Find(x => x.Id.Equals(item)).Adapt<OrganizeSelectorOutput>();
|
||||
if (addItem.type != null && addItem.type.Equals("company")) addItem.icon = "icon-ym icon-ym-tree-organization3";
|
||||
addItem.fullName = orgTree.FirstOrDefault(x => x.Id.Equals(addItem.id))?.Description;
|
||||
addItem.organize = addItem.fullName;
|
||||
addItem.organizeIds = addItem.organizeIdTree.Split(",").ToList();
|
||||
addItem.disabled = true;
|
||||
if (!treeList.Any(x => x.id.Equals(addItem.id))) treeList.Add(addItem);
|
||||
if (treeList.Select(x => x.id).Contains(item))
|
||||
{
|
||||
var addItem = orgTree.Find(x => x.Id.Equals(item)).Adapt<OrganizeSelectorOutput>();
|
||||
if (addItem.type != null && addItem.type.Equals("company")) addItem.icon = "icon-ym icon-ym-tree-organization3";
|
||||
addItem.fullName = orgTree.FirstOrDefault(x => x.Id.Equals(addItem.id))?.Description;
|
||||
addItem.organize = addItem.fullName;
|
||||
addItem.organizeIds = addItem.organizeIdTree.Split(",").ToList();
|
||||
addItem.disabled = true;
|
||||
if (!treeList.Any(x => x.id.Equals(addItem.id))) treeList.Add(addItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -282,6 +286,23 @@ public class OrganizeService : IOrganizeService, IDynamicApiController, ITransie
|
||||
|
||||
#region POST
|
||||
|
||||
/// <summary>
|
||||
/// 根据组织Id List 获取当前所属组织(部门).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("getDefaultCurrentValueDepartmentId")]
|
||||
public async Task<dynamic> GetDefaultCurrentValueDepartmentId([FromBody] GetDefaultCurrentValueInput input)
|
||||
{
|
||||
var depId = _repository.AsSugarClient().Queryable<UserEntity>().Where(x => x.Id.Equals(_userManager.UserId)).Select(x => x.OrganizeId).First();
|
||||
|
||||
if (input.DepartIds == null || !input.DepartIds.Any()) return new { departmentId = depId };
|
||||
var userRelationList = _repository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => input.DepartIds.Contains(x.ObjectId))
|
||||
.Select(x => x.UserId).ToList();
|
||||
|
||||
if (userRelationList.Contains(_userManager.UserId)) return new { userId = depId };
|
||||
else return new { departmentId = string.Empty };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过部门id获取部门列表.
|
||||
/// </summary>
|
||||
@@ -295,19 +316,19 @@ public class OrganizeService : IOrganizeService, IDynamicApiController, ITransie
|
||||
queryWhere = queryWhere.And(x => x.DeleteMark == null);
|
||||
List<OrganizeListOutput>? data = await _repository.AsQueryable().Where(queryWhere)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword)).Select(a => new OrganizeListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
organizeIdTree = a.OrganizeIdTree,
|
||||
type = a.Category,
|
||||
parentId = a.ParentId,
|
||||
lastFullName = a.FullName,
|
||||
fullName = a.FullName,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
icon = a.Category.Equals("company") ? "icon-ym icon-ym-tree-organization3" : "icon-ym icon-ym-tree-department1",
|
||||
sortCode = a.SortCode,
|
||||
isLeaf = true
|
||||
}).ToListAsync();
|
||||
{
|
||||
id = a.Id,
|
||||
organizeIdTree = a.OrganizeIdTree,
|
||||
type = a.Category,
|
||||
parentId = a.ParentId,
|
||||
lastFullName = a.FullName,
|
||||
fullName = a.FullName,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
icon = a.Category.Equals("company") ? "icon-ym icon-ym-tree-organization3" : "icon-ym icon-ym-tree-department1",
|
||||
sortCode = a.SortCode,
|
||||
isLeaf = true
|
||||
}).ToListAsync();
|
||||
|
||||
// 获取所有组织
|
||||
List<OrganizeEntity>? allOrgList = GetOrgListTreeName();
|
||||
@@ -398,7 +419,7 @@ public class OrganizeService : IOrganizeService, IDynamicApiController, ITransie
|
||||
});
|
||||
});
|
||||
|
||||
if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
if(adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
#endregion
|
||||
|
||||
#region 第三方同步
|
||||
|
||||
@@ -124,78 +124,29 @@ public class PositionService : IPositionService, IDynamicApiController, ITransie
|
||||
childOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().ToChildList(x => x.ParentId, input.organizeId).Select(x => x.Id).ToList());
|
||||
childOrgIds = childOrgIds.Distinct().ToList();
|
||||
}
|
||||
var strChildOrgIds = string.Join(",", childOrgIds);
|
||||
var data = await _repository.AsSugarClient().Queryable<PositionEntity, OrganizeEntity, DictionaryDataEntity>(
|
||||
(a, b, c) => new JoinQueryInfos(JoinType.Left, b.Id == a.OrganizeId, JoinType.Left, a.Type == c.EnCode && c.DictionaryTypeId == "dae93f2fd7cd4df999d32f8750fa6a1e"))
|
||||
|
||||
SqlSugarPagedList<PositionListOutput>? data = new SqlSugarPagedList<PositionListOutput>();
|
||||
if (childOrgIds.Any())
|
||||
{
|
||||
// 拼接查询
|
||||
List<ISugarQueryable<PositionListOutput>>? listQuery = new List<ISugarQueryable<PositionListOutput>>();
|
||||
foreach (string item in childOrgIds)
|
||||
// 组织机构
|
||||
.WhereIF(childOrgIds.Any(), a => childOrgIds.Contains(a.OrganizeId))
|
||||
.WhereIF(!_userManager.IsAdministrator, a => dataScope.Contains(a.OrganizeId))
|
||||
|
||||
// 关键字(名称、编码)
|
||||
.WhereIF(!input.keyword.IsNullOrEmpty(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Where(a => a.DeleteMark == null).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc).OrderBy(a => a.LastModifyTime, OrderByType.Desc)
|
||||
.Select((a, b, c) => new PositionListOutput
|
||||
{
|
||||
var quer = _repository.AsQueryable()
|
||||
|
||||
// 组织机构
|
||||
.Where(a => item.Equals(a.OrganizeId))
|
||||
.WhereIF(!_userManager.IsAdministrator, a => dataScope.Contains(a.OrganizeId))
|
||||
.WhereIF(!input.keyword.IsNullOrEmpty(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Select(a => new PositionListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = a.FullName,
|
||||
enCode = a.EnCode,
|
||||
type = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.EnCode.Equals(a.Type) && d.DictionaryTypeId == "dae93f2fd7cd4df999d32f8750fa6a1e").Select(d => d.FullName),
|
||||
department = SqlFunc.Subqueryable<OrganizeEntity>().Where(o => o.Id.Equals(a.OrganizeId)).Select(o => o.FullName),
|
||||
organizeId = SqlFunc.Subqueryable<OrganizeEntity>().Where(o => o.Id.Equals(a.OrganizeId)).Select(o => o.OrganizeIdTree),
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
description = a.Description,
|
||||
sortCode = a.SortCode
|
||||
});
|
||||
listQuery.Add(quer);
|
||||
}
|
||||
|
||||
data = await _repository.AsSugarClient().UnionAll(listQuery)
|
||||
.Select(a => new PositionListOutput
|
||||
{
|
||||
id = a.id,
|
||||
fullName = a.fullName,
|
||||
enCode = a.enCode,
|
||||
type = a.type,
|
||||
department = a.department,
|
||||
organizeId = a.organizeId,
|
||||
enabledMark = a.enabledMark,
|
||||
creatorTime = a.creatorTime,
|
||||
description = a.description,
|
||||
sortCode = a.sortCode
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = await _repository.AsSugarClient().Queryable<PositionEntity, OrganizeEntity, DictionaryDataEntity>(
|
||||
(a, b, c) => new JoinQueryInfos(JoinType.Left, b.Id == a.OrganizeId, JoinType.Left, a.Type == c.EnCode && c.DictionaryTypeId == "dae93f2fd7cd4df999d32f8750fa6a1e"))
|
||||
|
||||
// 组织机构
|
||||
.WhereIF(childOrgIds.Any(), a => childOrgIds.Contains(a.OrganizeId))
|
||||
.WhereIF(!_userManager.IsAdministrator, a => dataScope.Contains(a.OrganizeId))
|
||||
|
||||
// 关键字(名称、编码)
|
||||
.WhereIF(!input.keyword.IsNullOrEmpty(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Where(a => a.DeleteMark == null).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc).OrderBy(a => a.LastModifyTime, OrderByType.Desc)
|
||||
.Select((a, b, c) => new PositionListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = a.FullName,
|
||||
enCode = a.EnCode,
|
||||
type = c.FullName,
|
||||
department = b.FullName,
|
||||
organizeId = b.OrganizeIdTree,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
description = a.Description,
|
||||
sortCode = a.SortCode
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}
|
||||
id = a.Id,
|
||||
fullName = a.FullName,
|
||||
enCode = a.EnCode,
|
||||
type = c.FullName,
|
||||
department = b.FullName,
|
||||
organizeId = b.OrganizeIdTree,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
description = a.Description,
|
||||
sortCode = a.SortCode
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
// 处理组织树 名称
|
||||
List<OrganizeEntity>? orgList = _organizeService.GetOrgListTreeName();
|
||||
|
||||
@@ -102,62 +102,42 @@ public class RoleService : IRoleService, IDynamicApiController, ITransient
|
||||
SqlSugarPagedList<RoleListOutput>? data = new SqlSugarPagedList<RoleListOutput>();
|
||||
if (childOrgIds.Any())
|
||||
{
|
||||
// 拼接查询
|
||||
List<ISugarQueryable<RoleListOutput>>? listQuery = new List<ISugarQueryable<RoleListOutput>>();
|
||||
foreach (string item in childOrgIds)
|
||||
{
|
||||
var quer = _repository.AsSugarClient().Queryable<OrganizeRelationEntity, RoleEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.ObjectId))
|
||||
.Where((a, b) => item == a.OrganizeId)
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => b.FullName.Contains(pageInput.keyword) || b.EnCode.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator, a => dataScope.Contains(a.ObjectId))
|
||||
.Where((a, b) => b.DeleteMark == null)
|
||||
data = await _repository.AsSugarClient().Queryable<RoleEntity, OrganizeRelationEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.Id == b.ObjectId))
|
||||
.Where((a, b) => childOrgIds.Contains(b.OrganizeId)).Where((a, b) => a.DeleteMark == null)
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => a.FullName.Contains(pageInput.keyword) || a.EnCode.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator, (a, b) => dataScope.Contains(b.OrganizeId))
|
||||
.GroupBy((a, b) => new { a.Id, a.Type, a.GlobalMark, a.EnCode, a.FullName, a.EnabledMark, a.CreatorTime, a.SortCode })
|
||||
.Select((a, b) => new RoleListOutput
|
||||
{
|
||||
id = b.Id,
|
||||
parentId = b.Type,
|
||||
type = SqlFunc.IIF(b.GlobalMark == 1, "全局", "组织"),
|
||||
enCode = b.EnCode,
|
||||
fullName = b.FullName,
|
||||
enabledMark = b.EnabledMark,
|
||||
creatorTime = b.CreatorTime,
|
||||
sortCode = b.SortCode
|
||||
});
|
||||
listQuery.Add(quer);
|
||||
}
|
||||
var sql = _repository.AsSugarClient().UnionAll(listQuery).Where(a => !SqlFunc.IsNullOrEmpty(a.id)).ToSqlString();
|
||||
data = await _repository.AsSugarClient().UnionAll(listQuery).Where(a => !SqlFunc.IsNullOrEmpty(a.id))
|
||||
.GroupBy(a => new { a.id, a.parentId, a.type, a.creatorTime, a.enCode, a.fullName, a.sortCode, a.enabledMark })
|
||||
.Select(a => new RoleListOutput
|
||||
{
|
||||
id = a.id,
|
||||
parentId = a.parentId,
|
||||
type = a.type,
|
||||
creatorTime = a.creatorTime,
|
||||
enCode = a.enCode,
|
||||
fullName = a.fullName,
|
||||
sortCode = a.sortCode
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
id = a.Id,
|
||||
parentId = a.Type,
|
||||
type = SqlFunc.IIF(a.GlobalMark == 1, "全局", "组织"),
|
||||
enCode = a.EnCode,
|
||||
fullName = a.FullName,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
sortCode = a.SortCode
|
||||
}).MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = await _repository.AsSugarClient().Queryable<RoleEntity>()
|
||||
.WhereIF(input.organizeId == "0", a => a.GlobalMark == 1)
|
||||
.WhereIF(!_userManager.IsAdministrator, a => a.GlobalMark == 0)
|
||||
.WhereIF(!_userManager.IsAdministrator, a => a.GlobalMark == 1)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.keyword), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Where(a => a.DeleteMark == null)
|
||||
.Select((a) => new RoleListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
parentId = a.Type,
|
||||
type = SqlFunc.IIF(a.GlobalMark == 1, "全局", "组织"),
|
||||
enCode = a.EnCode,
|
||||
fullName = a.FullName,
|
||||
description = a.Description,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
sortCode = a.SortCode
|
||||
}).MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
data = await _repository.AsSugarClient().Queryable<RoleEntity, OrganizeRelationEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.Id == b.ObjectId))
|
||||
.Where((a, b) => a.DeleteMark == null)
|
||||
.WhereIF(input.organizeId == "0", (a, b) => a.GlobalMark == 1)
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => a.FullName.Contains(pageInput.keyword) || a.EnCode.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator && input.organizeId != "0", (a, b) => dataScope.Contains(b.OrganizeId))
|
||||
.GroupBy((a, b) => new { a.Id, a.Type, a.GlobalMark, a.EnCode, a.FullName, a.EnabledMark, a.CreatorTime, a.SortCode })
|
||||
.Select((a, b) => new RoleListOutput
|
||||
{
|
||||
id = a.Id,
|
||||
parentId = a.Type,
|
||||
type = SqlFunc.IIF(a.GlobalMark == 1, "全局", "组织"),
|
||||
enCode = a.EnCode,
|
||||
fullName = a.FullName,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorTime = a.CreatorTime,
|
||||
sortCode = a.SortCode
|
||||
}).MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}
|
||||
|
||||
#region 处理 多组织
|
||||
@@ -169,11 +149,8 @@ public class RoleService : IRoleService, IDynamicApiController, ITransient
|
||||
// 获取组织集合
|
||||
var organizeList = orgUserIdAll.Where(x => x.ObjectId == item.id).Select(x => x.OrganizeId).ToList();
|
||||
item.organizeInfo = string.Join(" ; ", orgTreeNameList.Where(x => organizeList.Contains(x.Id)).Select(x => x.Description));
|
||||
item.sortCode = 999;
|
||||
if (organizeList.Contains(input.organizeId)) item.sortCode = 0;
|
||||
}
|
||||
|
||||
data.list = data.list.OrderBy(x => x.sortCode).ToList();
|
||||
#endregion
|
||||
|
||||
return PageResult<RoleListOutput>.SqlSugarPageResult(data);
|
||||
|
||||
@@ -354,7 +354,7 @@ public class SocialsUserService : ISocialsUserService, IDynamicApiController, IT
|
||||
return new WeChatOpenAuthRequest(clientConfig, authStateCache);
|
||||
|
||||
case DefaultAuthSourceEnum.WECHAT_ENTERPRISE:
|
||||
//return new WeChatEnterpriseAuthRequest(clientConfig, authStateCache);
|
||||
//return new WeChatEnterpriseAuthRequest(clientConfig, authStateCache);
|
||||
|
||||
case DefaultAuthSourceEnum.WECHAT_ENTERPRISE_SCAN:
|
||||
clientConfig.redirectUri = HttpUtility.UrlEncode(clientConfig.redirectUri);
|
||||
@@ -554,4 +554,5 @@ public class SocialsUserService : ISocialsUserService, IDynamicApiController, IT
|
||||
var socialName = resData.username.IsNullOrWhiteSpace() ? resData.nickname : resData.username;
|
||||
return await GetUserInfo(model.source, uuid, socialName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ using JNPF.Systems.Entitys.Model.UsersCurrent;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
@@ -50,11 +51,21 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
/// </summary>
|
||||
private readonly ICacheManager _cacheManager;
|
||||
|
||||
/// <summary>
|
||||
/// 系统配置.
|
||||
/// </summary>
|
||||
private readonly ISysConfigService _sysConfigService;
|
||||
|
||||
/// <summary>
|
||||
/// 用户管理.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 操作权限服务.
|
||||
/// </summary>
|
||||
private readonly OnlineUserService _onlineUserService;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="UsersCurrentService"/>类型的新实例.
|
||||
/// </summary>
|
||||
@@ -63,12 +74,16 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
IAuthorizeService authorizeService,
|
||||
IOrganizeService organizeService,
|
||||
ICacheManager cacheManager,
|
||||
ISysConfigService sysConfigService,
|
||||
OnlineUserService onlineUserService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = userRepository;
|
||||
_authorizeService = authorizeService;
|
||||
_organizeService = organizeService;
|
||||
_cacheManager = cacheManager;
|
||||
_sysConfigService = sysConfigService;
|
||||
_onlineUserService = onlineUserService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
@@ -126,7 +141,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
position = string.Empty,
|
||||
positionId = a.PositionId,
|
||||
organizeId = a.OrganizeId,
|
||||
manager = SqlFunc.Subqueryable<UserEntity>().Where(x => x.Id.Equals(a.Id)).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)),
|
||||
manager = SqlFunc.Subqueryable<UserEntity>().Where(x => x.Id.Equals(a.ManagerId)).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)),
|
||||
roleId = string.Empty,
|
||||
roleIds = a.RoleId,
|
||||
creatorTime = a.CreatorTime,
|
||||
@@ -305,6 +320,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
if (MD5Encryption.Encrypt(input.oldPassword + user.Secretkey) != user.Password.ToLower())
|
||||
throw Oops.Oh(ErrorCode.D5007);
|
||||
string? imageCode = await GetCode(input.timestamp);
|
||||
await PwdStrategy(input);
|
||||
if (!input.code.ToLower().Equals(imageCode.ToLower()))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D5015);
|
||||
@@ -312,15 +328,14 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
else
|
||||
{
|
||||
await DelCode(input.timestamp);
|
||||
await DelUserInfo(string.Format("{0}_{1}", _userManager.TenantId, user.Id));
|
||||
await DelUserInfo(_userManager.TenantId, user.Id);
|
||||
await _onlineUserService.ForcedOffline(user.Id);
|
||||
}
|
||||
|
||||
user.Password = MD5Encryption.Encrypt(input.password + user.Secretkey);
|
||||
user.ChangePasswordDate = DateTime.Now;
|
||||
user.LastModifyTime = DateTime.Now;
|
||||
user.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new {
|
||||
it.Password,
|
||||
it.ChangePasswordDate,
|
||||
it.LastModifyUserId,
|
||||
@@ -341,8 +356,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
userInfo.IsAdministrator = Convert.ToInt32(_userManager.IsAdministrator);
|
||||
userInfo.LastModifyTime = DateTime.Now;
|
||||
userInfo.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(userInfo).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(userInfo).UpdateColumns(it => new {
|
||||
it.RealName,
|
||||
it.Signature,
|
||||
it.Gender,
|
||||
@@ -376,8 +390,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
user.Theme = input.theme;
|
||||
user.LastModifyTime = DateTime.Now;
|
||||
user.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new {
|
||||
it.Theme,
|
||||
it.LastModifyUserId,
|
||||
it.LastModifyTime
|
||||
@@ -396,8 +409,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
user.Language = input.language;
|
||||
user.LastModifyTime = DateTime.Now;
|
||||
user.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new {
|
||||
it.Language,
|
||||
it.LastModifyUserId,
|
||||
it.LastModifyTime
|
||||
@@ -416,8 +428,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
user.HeadIcon = name;
|
||||
user.LastModifyTime = DateTime.Now;
|
||||
user.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(user).UpdateColumns(it => new {
|
||||
it.HeadIcon,
|
||||
it.LastModifyUserId,
|
||||
it.LastModifyTime
|
||||
@@ -468,8 +479,17 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
if (input.menuType.Equals(1))
|
||||
{
|
||||
// 系统下没有菜单不允许切换.
|
||||
if (!await _repository.AsSugarClient().Queryable<ModuleEntity>().AnyAsync(x => x.SystemId.Equals(input.majorId) && x.DeleteMark == null && x.Category.Equals("App")))
|
||||
throw Oops.Oh(ErrorCode.D4009);
|
||||
var mList = await _repository.AsSugarClient().Queryable<ModuleEntity>().Where(x => x.SystemId.Equals(input.majorId) && x.DeleteMark == null && x.Category.Equals("App")).Select(x => x.Id).ToListAsync();
|
||||
if (!mList.Any()) throw Oops.Oh(ErrorCode.D4009);
|
||||
|
||||
List<string>? roleList = await _userManager.GetUserOrgRoleIds(userInfo.RoleId, userInfo.OrganizeId);
|
||||
|
||||
// 非管理员 没有任何权限 切换失败
|
||||
if (!_userManager.IsAdministrator && !_repository.AsSugarClient().Queryable<AuthorizeEntity>()
|
||||
.Where(x => x.ObjectType == "Role" && x.ItemType == "module" && roleList.Contains(x.ObjectId))
|
||||
.Where(x => mList.Contains(x.ItemId)).Any())
|
||||
throw Oops.Oh(ErrorCode.D5023);
|
||||
|
||||
userInfo.SystemId = input.majorId;
|
||||
}
|
||||
else
|
||||
@@ -501,8 +521,7 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
|
||||
userInfo.LastModifyTime = DateTime.Now;
|
||||
userInfo.LastModifyUserId = _userManager.UserId;
|
||||
int isOk = await _repository.AsUpdateable(userInfo).UpdateColumns(it => new
|
||||
{
|
||||
int isOk = await _repository.AsUpdateable(userInfo).UpdateColumns(it => new {
|
||||
it.OrganizeId,
|
||||
it.PositionId,
|
||||
it.LastModifyUserId,
|
||||
@@ -709,14 +728,48 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController,
|
||||
/// <summary>
|
||||
/// 删除用户登录信息缓存.
|
||||
/// </summary>
|
||||
/// <param name="tenantId">租户ID.</param>
|
||||
/// <param name="userId">用户ID.</param>
|
||||
/// <returns></returns>
|
||||
private Task<bool> DelUserInfo(string userId)
|
||||
private Task<bool> DelUserInfo(string tenantId, string userId)
|
||||
{
|
||||
string? cacheKey = string.Format("{0}{1}", CommonConst.CACHEKEYUSER, userId);
|
||||
string? cacheKey = string.Format("{0}:{1}:{2}", tenantId, CommonConst.CACHEKEYUSER, userId);
|
||||
_cacheManager.DelAsync(cacheKey);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 密码策略验证.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task PwdStrategy(UsersCurrentActionsModifyPasswordInput input)
|
||||
{
|
||||
// 系统配置信息
|
||||
var sysInfo = await _sysConfigService.GetInfo();
|
||||
// 禁用旧密码
|
||||
if (sysInfo.disableOldPassword == 1 && sysInfo.disableTheNumberOfOldPasswords > 0)
|
||||
{
|
||||
var oldPwdList = _repository.AsSugarClient().Queryable<UserOldPasswordEntity>().Where(x => x.UserId == _userManager.UserId).OrderByDescending(o => o.CreatorTime).Take(sysInfo.disableTheNumberOfOldPasswords).ToList();
|
||||
if (oldPwdList.Any())
|
||||
{
|
||||
foreach (var item in oldPwdList)
|
||||
{
|
||||
if (MD5Encryption.Encrypt(input.password + item.Secretkey) == item.OldPassword.ToLower())
|
||||
throw Oops.Oh(ErrorCode.D5026);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存旧密码数据
|
||||
var oldPwdEntity = new UserOldPasswordEntity();
|
||||
oldPwdEntity.Id = SnowflakeIdHelper.NextId();
|
||||
oldPwdEntity.UserId = _userManager.UserId;
|
||||
oldPwdEntity.Account = _userManager.Account;
|
||||
oldPwdEntity.OldPassword = MD5Encryption.Encrypt(input.password + _userManager.User.Secretkey);
|
||||
oldPwdEntity.Secretkey = _userManager.User.Secretkey;
|
||||
oldPwdEntity.CreatorTime = DateTime.Now;
|
||||
oldPwdEntity.TenantId = _userManager.TenantId;
|
||||
_repository.AsSugarClient().Insertable(oldPwdEntity).ExecuteCommand();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using JNPF.Common.Configuration;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Core.Manager.Files;
|
||||
using JNPF.Common.Dtos.OAuth;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
@@ -9,27 +11,42 @@ using JNPF.Common.Helper;
|
||||
using JNPF.Common.Manager;
|
||||
using JNPF.Common.Models.NPOI;
|
||||
using JNPF.Common.Models.User;
|
||||
using JNPF.Common.Options;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DatabaseAccessor;
|
||||
using JNPF.DataEncryption;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.DatabaseAccessor.SqlSugar.Models;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.RemoteRequest.Extensions;
|
||||
using JNPF.Systems.Entitys.Dto.Organize;
|
||||
using JNPF.Systems.Entitys.Dto.Role;
|
||||
using JNPF.Systems.Entitys.Dto.SysConfig;
|
||||
using JNPF.Systems.Entitys.Dto.User;
|
||||
using JNPF.Systems.Entitys.Dto.UserRelation;
|
||||
using JNPF.Systems.Entitys.Enum;
|
||||
using JNPF.Systems.Entitys.Model.Permission.User;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NPOI.SS.Formula.Eval;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using Qiniu.Util;
|
||||
using Senparc.NeuChar.App.AppStore;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Principal;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace JNPF.Systems;
|
||||
|
||||
@@ -40,6 +57,11 @@ namespace JNPF.Systems;
|
||||
[Route("api/permission/[controller]")]
|
||||
public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置文档.
|
||||
/// </summary>
|
||||
private readonly OauthOptions _oauthOptions = App.GetConfig<OauthOptions>("OAuth", true);
|
||||
|
||||
/// <summary>
|
||||
/// 服务基础仓储.
|
||||
/// </summary>
|
||||
@@ -80,6 +102,16 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// SqlSugarClient客户端.
|
||||
/// </summary>
|
||||
private SqlSugarScope _sqlSugarClient;
|
||||
|
||||
/// <summary>
|
||||
/// 多租户配置选项.
|
||||
/// </summary>
|
||||
private readonly TenantOptions _tenant;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="UsersService"/>类型的新实例.
|
||||
/// </summary>
|
||||
@@ -91,6 +123,8 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
ISynThirdInfoService synThirdInfoService,
|
||||
ICacheManager cacheManager,
|
||||
IFileManager fileService,
|
||||
ISqlSugarClient sqlSugarClient,
|
||||
IOptions<TenantOptions> tenantOptions,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = userRepository;
|
||||
@@ -101,6 +135,8 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
_cacheManager = cacheManager;
|
||||
_synThirdInfoService = synThirdInfoService;
|
||||
_fileManager = fileService;
|
||||
_tenant = tenantOptions.Value;
|
||||
_sqlSugarClient = (SqlSugarScope)sqlSugarClient;
|
||||
}
|
||||
|
||||
#region GET
|
||||
@@ -140,70 +176,26 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
ErrorStrategy configLockType = (ErrorStrategy)Enum.Parse(typeof(ErrorStrategy), config?.Value);
|
||||
|
||||
SqlSugarPagedList<UserListOutput>? data = new SqlSugarPagedList<UserListOutput>();
|
||||
if (childOrgIds.Any())
|
||||
{
|
||||
// 拼接查询
|
||||
List<ISugarQueryable<UserListOutput>>? listQuery = new List<ISugarQueryable<UserListOutput>>();
|
||||
foreach (string item in childOrgIds)
|
||||
{
|
||||
var quer = _repository.AsSugarClient().Queryable<UserRelationEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.UserId))
|
||||
.Where((a, b) => item == a.ObjectId)
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => b.Account.Contains(pageInput.keyword) || b.RealName.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator, a => dataScope.Contains(a.ObjectId))
|
||||
.Where((a, b) => b.DeleteMark == null && !b.Id.Equals("admin"))
|
||||
.Select((a, b) => new UserListOutput
|
||||
{
|
||||
id = b.Id,
|
||||
account = b.Account,
|
||||
realName = b.RealName,
|
||||
headIcon = b.HeadIcon,
|
||||
creatorTime = b.CreatorTime,
|
||||
gender = b.Gender,
|
||||
mobilePhone = b.MobilePhone,
|
||||
sortCode = b.SortCode,
|
||||
unLockTime = b.UnLockTime,
|
||||
enabledMark = b.EnabledMark
|
||||
});
|
||||
listQuery.Add(quer);
|
||||
}
|
||||
|
||||
data = await _repository.AsSugarClient().UnionAll(listQuery)
|
||||
.GroupBy(a => new { a.id, a.account, a.realName, a.creatorTime, a.gender, a.mobilePhone, a.sortCode, a.enabledMark, a.unLockTime })
|
||||
.Select(a => new UserListOutput
|
||||
{
|
||||
id = a.id,
|
||||
account = a.account,
|
||||
realName = a.realName,
|
||||
creatorTime = a.creatorTime,
|
||||
gender = a.gender,
|
||||
mobilePhone = a.mobilePhone,
|
||||
sortCode = a.sortCode,
|
||||
enabledMark = SqlFunc.IIF(configLockType == ErrorStrategy.Delay && a.enabledMark == 2 && a.unLockTime < DateTime.Now, 1, a.enabledMark)
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
var userHeadIcon = await _repository.AsQueryable().Where(x => data.list.Select(xx => xx.id).Contains(x.Id)).Select(x => new { Id = x.Id, headIcon = x.HeadIcon }).ToListAsync();
|
||||
foreach (var item in data.list) item.headIcon = "/api/File/Image/userAvatar/" + userHeadIcon.Find(x => x.Id.Equals(item.id)).headIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = await _repository.AsSugarClient().Queryable<UserRelationEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.UserId))
|
||||
.Where((a, b) => b.DeleteMark == null && !b.Id.Equals("admin"))
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => b.Account.Contains(pageInput.keyword) || b.RealName.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator, (a, b) => dataScope.Contains(a.ObjectId))
|
||||
.OrderBy((a, b) => b.SortCode).OrderBy((a, b) => b.CreatorTime, OrderByType.Desc).OrderBy((a, b) => b.LastModifyTime, OrderByType.Desc)
|
||||
.GroupBy((a, b) => new { b.Id, b.Account, b.RealName, b.CreatorTime, b.LastModifyTime, b.Gender, b.MobilePhone, b.SortCode, b.EnabledMark, b.UnLockTime })
|
||||
.Select((a, b) => new UserListOutput
|
||||
{
|
||||
id = b.Id,
|
||||
account = b.Account,
|
||||
realName = b.RealName,
|
||||
headIcon = SqlFunc.Subqueryable<UserEntity>().Where(e => e.Id == b.Id).Select(u => SqlFunc.MergeString("/api/File/Image/userAvatar/", u.HeadIcon)),
|
||||
creatorTime = b.CreatorTime,
|
||||
gender = b.Gender,
|
||||
mobilePhone = b.MobilePhone,
|
||||
sortCode = b.SortCode,
|
||||
enabledMark = SqlFunc.IIF(configLockType == ErrorStrategy.Delay && b.EnabledMark == 2 && b.UnLockTime < DateTime.Now, 1, b.EnabledMark)
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
}
|
||||
data = await _repository.AsSugarClient().Queryable<UserRelationEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.UserId))
|
||||
.Where((a, b) => b.DeleteMark == null && !b.Account.Equals("admin"))
|
||||
.WhereIF(childOrgIds.Any(), (a, b) => childOrgIds.Contains(a.ObjectId))
|
||||
.WhereIF(!pageInput.keyword.IsNullOrEmpty(), (a, b) => b.Account.Contains(pageInput.keyword) || b.RealName.Contains(pageInput.keyword))
|
||||
.WhereIF(!_userManager.IsAdministrator, (a, b) => dataScope.Contains(a.ObjectId))
|
||||
.OrderBy((a, b) => b.SortCode).OrderBy((a, b) => b.CreatorTime, OrderByType.Desc).OrderBy((a, b) => b.LastModifyTime, OrderByType.Desc)
|
||||
.GroupBy((a, b) => new { b.Id, b.Account, b.RealName, b.CreatorTime, b.LastModifyTime, b.Gender, b.MobilePhone, b.SortCode, b.EnabledMark, b.UnLockTime })
|
||||
.Select((a, b) => new UserListOutput
|
||||
{
|
||||
id = b.Id,
|
||||
account = b.Account,
|
||||
realName = b.RealName,
|
||||
headIcon = SqlFunc.Subqueryable<UserEntity>().Where(e => e.Id == b.Id).Select(u => SqlFunc.MergeString("/api/File/Image/userAvatar/", u.HeadIcon)),
|
||||
creatorTime = b.CreatorTime,
|
||||
gender = b.Gender,
|
||||
mobilePhone = b.MobilePhone,
|
||||
sortCode = b.SortCode,
|
||||
enabledMark = SqlFunc.IIF(configLockType == ErrorStrategy.Delay && b.EnabledMark == 2 && b.UnLockTime < DateTime.Now, 1, b.EnabledMark)
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
#region 处理 用户 多组织
|
||||
|
||||
@@ -214,11 +206,8 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
// 获取用户组织集合
|
||||
item.organizeList = orgUserIdAll.Where(x => x.UserId == item.id).Select(x => x.ObjectId).ToList();
|
||||
item.organize = string.Join(" ; ", orgTreeNameList.Where(x => item.organizeList.Contains(x.Id)).Select(x => x.Description));
|
||||
item.sortCode = 999;
|
||||
if (item.organizeList.Contains(input.organizeId)) item.sortCode = 0;
|
||||
}
|
||||
|
||||
data.list = data.list.OrderBy(x => x.sortCode).ToList();
|
||||
#endregion
|
||||
|
||||
return PageResult<UserListOutput>.SqlSugarPageResult(data);
|
||||
@@ -323,8 +312,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
.Where((a, b) => b.ObjectType == "Organize" && orgList.Contains(b.ObjectId)).Where((a, b) => a.EnabledMark == 1 && a.DeleteMark == null)
|
||||
.Where((a, b) => a.RealName.Contains(input.keyword) || a.Account.Contains(input.keyword))
|
||||
.GroupBy((a, b) => new { a.Id, a.RealName, a.Account, a.EnabledMark })
|
||||
.Select((a, b) => new
|
||||
{
|
||||
.Select((a, b) => new {
|
||||
id = a.Id,
|
||||
fullName = SqlFunc.MergeString(a.RealName, "/", a.Account),
|
||||
enabledMark = a.EnabledMark,
|
||||
@@ -369,8 +357,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
var res = await _repository.AsSugarClient().Queryable<UserEntity, UserRelationEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.UserId == a.Id))
|
||||
.Where((a, b) => b.ObjectType == "Organize" && b.ObjectId == input.organizeId).Where((a, b) => a.EnabledMark == 1 && a.DeleteMark == null)
|
||||
.GroupBy((a, b) => new { a.Id, a.RealName, a.Account, a.EnabledMark })
|
||||
.Select((a, b) => new
|
||||
{
|
||||
.Select((a, b) => new {
|
||||
id = a.Id,
|
||||
fullName = SqlFunc.MergeString(a.RealName, "/", a.Account),
|
||||
enabledMark = a.EnabledMark,
|
||||
@@ -527,6 +514,24 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
|
||||
#region POST
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户Id List 获取当前用户Id.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("getDefaultCurrentValueUserId")]
|
||||
public async Task<dynamic> GetDefaultCurrentValueUserId([FromBody] GetDefaultCurrentValueInput input)
|
||||
{
|
||||
if ((input.UserIds == null || !input.UserIds.Any()) && (input.DepartIds == null || !input.DepartIds.Any()) && (input.PositionIds == null || !input.PositionIds.Any())
|
||||
&& (input.RoleIds == null || !input.RoleIds.Any()) && (input.GroupIds == null || !input.GroupIds.Any())) return new { userId = _userManager.UserId };
|
||||
|
||||
var userRelationList = _repository.AsSugarClient().Queryable<UserRelationEntity>().Select(x => new UserRelationEntity() { UserId = x.UserId, ObjectId = x.ObjectId }).ToList();
|
||||
var userIdList = userRelationList.Where(x => input.UserIds.Contains(x.UserId) || input.DepartIds.Contains(x.ObjectId)
|
||||
|| input.PositionIds.Contains(x.ObjectId) || input.RoleIds.Contains(x.ObjectId) || input.GroupIds.Contains(x.ObjectId)).Select(x => x.UserId).ToList();
|
||||
|
||||
if (userIdList.Contains(_userManager.UserId)) return new { userId = _userManager.UserId };
|
||||
else return new { userId = string.Empty };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取.
|
||||
/// </summary>
|
||||
@@ -534,16 +539,14 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
[HttpPost("GetUserList")]
|
||||
public async Task<dynamic> GetUserList([FromBody] UserRelationInput input)
|
||||
{
|
||||
var data = await _repository.AsSugarClient().Queryable<UserEntity, OrganizeEntity>((u, org) => new JoinQueryInfos(JoinType.Inner, u.OrganizeId == org.Id))
|
||||
.Where((u, org) => u.EnabledMark > 0 && u.DeleteMark == null)
|
||||
.Where((u, org) => input.userId.Contains(u.Id))
|
||||
.Select((u, org) => new OrganizeMemberListOutput()
|
||||
var data = await _repository.AsQueryable().Where(it => it.EnabledMark > 0 && it.DeleteMark == null)
|
||||
.Where(it => input.userId.Contains(it.Id))
|
||||
.Select(it => new OrganizeMemberListOutput()
|
||||
{
|
||||
id = u.Id,
|
||||
fullName = SqlFunc.MergeString(u.RealName, "/", u.Account),
|
||||
headIcon = SqlFunc.MergeString("/api/File/Image/userAvatar/", u.HeadIcon),
|
||||
enabledMark = u.EnabledMark,
|
||||
type = org.FullName,
|
||||
id = it.Id,
|
||||
fullName = SqlFunc.MergeString(it.RealName, "/", it.Account),
|
||||
headIcon = SqlFunc.MergeString("/api/File/Image/userAvatar/", it.HeadIcon),
|
||||
enabledMark = it.EnabledMark,
|
||||
}).ToListAsync();
|
||||
|
||||
data = data.OrderBy(x => input.userId.IndexOf(x.id)).ToList();
|
||||
@@ -561,6 +564,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
var oids = userList.Where(x => x.UserId.Equals(item.id)).Select(x => x.ObjectId).ToList();
|
||||
var oTree = orgList.Where(x => oids.Contains(x.Id)).Select(x => x.Description).ToList();
|
||||
item.organize = string.Join(",", oTree);
|
||||
//item.type = org.fullName;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -804,15 +808,12 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
if (input.roleIds != null) input.departIds.AddRange(input.roleIds);
|
||||
if (input.groupIds != null) input.departIds.AddRange(input.groupIds);
|
||||
if (!input.departIds.Any()) return PageResult<UserListOutput>.SqlSugarPageResult(data);
|
||||
data = await _repository.AsSugarClient().Queryable<UserRelationEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.UserId))
|
||||
var ids = await _repository.AsSugarClient().Queryable<UserRelationEntity, UserEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.UserId))
|
||||
.Where((a, b) => b.DeleteMark == null)
|
||||
.WhereIF(input.departIds.Any() || input.userIds.Any(), (a, b) => input.departIds.Contains(a.ObjectId) || input.userIds.Contains(b.Id))
|
||||
.WhereIF(input.pagination.keyword.IsNotEmptyOrNull(), (a, b) => b.Account.Contains(input.pagination.keyword) || b.RealName.Contains(input.pagination.keyword))
|
||||
.Select((a, b) => new UserListOutput()
|
||||
{
|
||||
id = b.Id
|
||||
}).Distinct().ToPagedListAsync(input.pagination.currentPage, input.pagination.pageSize);
|
||||
data = await _repository.AsQueryable().Where(x => data.list.Select(xx => xx.id).Contains(x.Id)).Select(x => new UserListOutput()
|
||||
.Select((a, b) => b.Id).Distinct().ToListAsync();
|
||||
data = await _repository.AsQueryable().Where(x => ids.Contains(x.Id)).Select(x => new UserListOutput()
|
||||
{
|
||||
id = x.Id,
|
||||
organizeId = x.OrganizeId,
|
||||
@@ -821,8 +822,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
headIcon = SqlFunc.MergeString("/api/File/Image/userAvatar/", x.HeadIcon),
|
||||
gender = x.Gender,
|
||||
mobilePhone = x.MobilePhone
|
||||
}).ToPagedListAsync(1, input.pagination.pageSize);
|
||||
|
||||
}).ToPagedListAsync(input.pagination.currentPage, input.pagination.pageSize);
|
||||
if (data.list.Any())
|
||||
{
|
||||
var orgList = _organizeService.GetOrgListTreeName();
|
||||
@@ -1075,6 +1075,9 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// 单点登录同步
|
||||
await syncUserInfo(entity, "create", _userManager.TenantId);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1130,6 +1133,9 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// 单点登录同步
|
||||
await syncUserInfo(entity, "delete", _userManager.TenantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1142,6 +1148,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
public async Task Update(string id, [FromBody] UserUpInput input)
|
||||
{
|
||||
UserEntity? oldUserEntity = await _repository.GetFirstAsync(it => it.Id == id);
|
||||
input.roleId = input.roleId == null ? string.Empty : input.roleId;
|
||||
|
||||
// 超级管理员 只有 admin 账号才有变更权限
|
||||
if (_userManager.UserId != oldUserEntity.Id && oldUserEntity.IsAdministrator == 1 && _userManager.Account != "admin")
|
||||
@@ -1233,8 +1240,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
try
|
||||
{
|
||||
// 更新用户记录
|
||||
int newEntity = await _repository.AsUpdateable(entity).UpdateColumns(it => new
|
||||
{
|
||||
int newEntity = await _repository.AsUpdateable(entity).UpdateColumns(it => new {
|
||||
it.Account,
|
||||
it.RealName,
|
||||
it.QuickQuery,
|
||||
@@ -1315,6 +1321,9 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// 单点登录同步
|
||||
await syncUserInfo(entity, "update", _userManager.TenantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1372,7 +1381,9 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
|
||||
if (!(isOk > 0)) throw Oops.Oh(ErrorCode.D5005);
|
||||
|
||||
// 强制将用户提掉线
|
||||
// 单点登录同步
|
||||
entity.Password = input.userPassword;
|
||||
await syncUserInfo(entity, "modifyPassword", _userManager.TenantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1794,6 +1805,8 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrivateMethod
|
||||
|
||||
/// <summary>
|
||||
/// 获取集合中的组织 树,根据上级ID.
|
||||
/// </summary>
|
||||
@@ -2256,5 +2269,244 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
||||
|
||||
return output;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 单点登录 数据同步
|
||||
|
||||
/// <summary>
|
||||
/// 同步数据导maxkey.
|
||||
/// </summary>
|
||||
/// <param name="userEntity"></param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="tenantId"></param>
|
||||
public async Task syncUserInfo(UserEntity userEntity, string method, string tenantId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_oauthOptions.Enabled)
|
||||
{
|
||||
var userName = string.Format("{0}:{1}", _oauthOptions.Pull.UserName, _oauthOptions.Pull.Password).ToBase64String();
|
||||
|
||||
// http调用结果
|
||||
HttpResponse execute = null;
|
||||
var map = parse(userEntity);
|
||||
tenantId = tenantId != null && tenantId.Length > 0 ? tenantId : "1";
|
||||
if (tenantId.Equals("default")) tenantId = "1";
|
||||
map.Add("instId", tenantId);
|
||||
|
||||
// 得到userId
|
||||
// String username = userEntity.get("id") != null && userEntity.get("id").toString().length() > 0 ? userEntity.get("id").toString() : null;
|
||||
|
||||
Dictionary<string, object> jsonObject = null;
|
||||
var resString = string.Empty;
|
||||
var headers = new Dictionary<string, object>();
|
||||
headers.Add("Authorization", _oauthOptions.Pull.CredentialType + " " + userName);
|
||||
|
||||
if (method.Equals("create"))
|
||||
{
|
||||
resString = await (_oauthOptions.Pull.CreateRestAddress + "?appId=" + _oauthOptions.Pull.UserName).SetHeaders(headers).SetBody(map).PostAsStringAsync();
|
||||
}
|
||||
else if (method.Equals("update"))
|
||||
{
|
||||
resString = await (_oauthOptions.Pull.ReplaceRestAddress + "?appId=" + _oauthOptions.Pull.UserName).SetHeaders(headers).SetBody(map).PutAsStringAsync();
|
||||
}
|
||||
else if (method.Equals("delete"))
|
||||
{
|
||||
resString = await (_oauthOptions.Pull.DeleteRestAddress + "?appId=" + _oauthOptions.Pull.UserName).SetHeaders(headers).SetBody(map).DeleteAsStringAsync();
|
||||
}
|
||||
else if (method.Equals("modifyPassword"))
|
||||
{
|
||||
resString = await (_oauthOptions.Pull.ChangePasswordRestAddress + "?appId=" + _oauthOptions.Pull.UserName).SetHeaders(headers).SetBody(map).PostAsStringAsync();
|
||||
}
|
||||
|
||||
// else if (method.Equals("modifyPassword")) {
|
||||
// jsonObject = HttpUtil.httpRequest(_oauthOptions.Pull.getGetRestAddress() + username
|
||||
// , "GET"
|
||||
// , null, _oauthOptions.Pull.getCredentialType() + " " + _oauthOptions.Pull.getUserName() + "Og==" + _oauthOptions.Pull.getPassword()
|
||||
// , null);
|
||||
// }
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, object> parse(UserEntity userEntity)
|
||||
{
|
||||
var map = new Dictionary<string, object>();
|
||||
|
||||
// map.Add("id", userEntity.get("id"));
|
||||
map.Add("username", userEntity.Account);
|
||||
map.Add("password", userEntity.Password);
|
||||
map.Add("mobile", userEntity.MobilePhone);
|
||||
map.Add("email", userEntity.Email);
|
||||
map.Add("gender", (int)userEntity.Gender == 1 ? 2 : 1);
|
||||
map.Add("createdBy", userEntity.CreatorUserId);
|
||||
map.Add("createdDate", userEntity.CreatorTime);
|
||||
map.Add("modifiedBy", userEntity.LastModifyUserId);
|
||||
map.Add("modifiedDate", userEntity.LastModifyTime);
|
||||
map.Add("displayName", userEntity.RealName);
|
||||
|
||||
// map.Add("managerId", userEntity.get("managerId"));
|
||||
// map.Add("departmentId", userEntity.get("organizeId"));
|
||||
map.Add("loginCount", userEntity.LogSuccessCount);
|
||||
map.Add("badPasswordCount", userEntity.LogErrorCount);
|
||||
map.Add("lastLoginIp", userEntity.LastLogIP);
|
||||
map.Add("lastLoginTime", userEntity.LastLogTime);
|
||||
map.Add("status", userEntity.EnabledMark != null ? (userEntity.EnabledMark == 1 ? 1 : 4) : 4);
|
||||
return map;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单点服务端消息 同步用户信息到数据库.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
[NonAction]
|
||||
public async Task<bool> Receive(string message)
|
||||
{
|
||||
bool isSuccess;
|
||||
var map = new Dictionary<string, object>();
|
||||
try
|
||||
{
|
||||
var mqMessage = message.ToObject<MqMessage>();
|
||||
|
||||
// 转成用户实体类
|
||||
var userInfo = mqMessage.content.ToObject<UserInfo>();
|
||||
var userEntity = new UserEntity();
|
||||
userEntity.Id = userInfo.id;
|
||||
userEntity.Account = userInfo.username;
|
||||
userEntity.MobilePhone = userInfo.mobile;
|
||||
userEntity.Email = userInfo.email;
|
||||
userEntity.Gender = userInfo.gender;
|
||||
userEntity.CreatorTime = userInfo.createdDate.IsNullOrWhiteSpace() ? null : userInfo.createdDate?.ParseToLong().TimeStampToDateTime();
|
||||
userEntity.CreatorUserId = userInfo.createdBy;
|
||||
userEntity.LastModifyUserId = userInfo.modifiedBy;
|
||||
userEntity.LastModifyTime = userInfo.modifiedDate.IsNullOrWhiteSpace() ? null : userInfo.modifiedDate?.ParseToLong().TimeStampToDateTime();
|
||||
userEntity.RealName = userInfo.displayName;
|
||||
userEntity.LogSuccessCount = userInfo.loginCount;
|
||||
userEntity.LogErrorCount = userInfo.badPasswordCount;
|
||||
userEntity.LastLogIP = userInfo.lastLoginIp;
|
||||
userEntity.LastLogTime = userInfo.lastLoginTime.IsNullOrWhiteSpace() ? null : userInfo.lastLoginTime?.ParseToLong().TimeStampToDateTime();
|
||||
userEntity.EnabledMark = userInfo.status == 1 ? 1 : 0;
|
||||
userEntity.HeadIcon = "001.png";
|
||||
|
||||
if (_tenant.MultiTenancy)
|
||||
{
|
||||
ConnectionConfigOptions options = new ConnectionConfigOptions();
|
||||
var interFace = string.Format("{0}{1}", _tenant.MultiTenancyDBInterFace, userInfo.instId);
|
||||
var response = interFace.GetAsStringAsync().Result;
|
||||
var result = response.ToObject<UnifyResult.RESTfulResult<TenantInterFaceOutput>>();
|
||||
if (result.code != 200)
|
||||
{
|
||||
throw Oops.Oh(result.msg);
|
||||
}
|
||||
else if (result.data.dotnet == null && result.data.linkList == null)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D1025);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.data.linkList == null || result.data.linkList?.Count == 0)
|
||||
{
|
||||
options = JNPFTenantExtensions.GetLinkToOrdinary(userInfo.instId, result.data.dotnet);
|
||||
}
|
||||
else if (result.data.dotnet == null)
|
||||
{
|
||||
options = JNPFTenantExtensions.GetLinkToCustom(userInfo.instId, result.data.linkList);
|
||||
}
|
||||
}
|
||||
if (!"default".Equals(userInfo.instId) && _tenant.MultiTenancyType.Equals("COLUMN"))
|
||||
{
|
||||
_sqlSugarClient.QueryFilter.AddTableFilter<ITenantFilter>(it => it.TenantId == userInfo.instId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sqlSugarClient.AddConnection(JNPFTenantExtensions.GetConfig(options));
|
||||
_sqlSugarClient.ChangeDatabase(userInfo.instId);
|
||||
}
|
||||
}
|
||||
|
||||
isSuccess = await process(userEntity, mqMessage.actionType, userInfo.instId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// _logger.error("同步用户失败", e);
|
||||
isSuccess = false;
|
||||
}
|
||||
|
||||
if (!isSuccess)
|
||||
{
|
||||
// _logger.info("消息消费失败:" + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _logger.debug("同步用户信息, {}", JSONObject.toJSONString(map));
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存到数据库处理逻辑.
|
||||
/// </summary>
|
||||
/// <param name="actionType"></param>
|
||||
/// <param name="instId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> process(UserEntity entity, string actionType, string instId)
|
||||
{
|
||||
if (actionType.Equals("CREATE_ACTION"))
|
||||
{
|
||||
if (_sqlSugarClient.Queryable<UserEntity>().Any(x => x.Account.Equals(entity.Account) && x.DeleteMark == null)) return true;
|
||||
entity.Secretkey = Guid.NewGuid().ToString();
|
||||
entity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + entity.Secretkey);
|
||||
|
||||
UserRelationEntity? entityRelation = new UserRelationEntity();
|
||||
entityRelation.Id = SnowflakeIdHelper.NextId();
|
||||
entityRelation.ObjectType = "Organize";
|
||||
entityRelation.ObjectId = _sqlSugarClient.Queryable<OrganizeEntity>().First(x => x.ParentId.Equals("-1")).Id;
|
||||
entityRelation.SortCode = 0;
|
||||
entityRelation.UserId = entity.Id;
|
||||
entityRelation.CreatorTime = DateTime.Now;
|
||||
entityRelation.CreatorUserId = entity.CreatorUserId;
|
||||
_sqlSugarClient.Insertable(entityRelation).ExecuteCommand(); // 批量新增用户关系
|
||||
|
||||
// 新增用户记录
|
||||
return await _sqlSugarClient.Insertable(entity).CallEntityMethod(m => m.Create()).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
else if (actionType.Equals("UPDATE_ACTION"))
|
||||
{
|
||||
var oldEntity = await _sqlSugarClient.Queryable<UserEntity>().FirstAsync(x => x.Account.Equals(entity.Account) && x.DeleteMark == null);
|
||||
entity.Id = oldEntity.Id;
|
||||
return await _sqlSugarClient.Updateable(entity).CallEntityMethod(m => m.LastModify()).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
else if (actionType.Equals("DELETE_ACTION"))
|
||||
{
|
||||
var oldEntity = await _sqlSugarClient.Queryable<UserEntity>().FirstAsync(x => x.Account.Equals(entity.Account) && x.DeleteMark == null);
|
||||
oldEntity.EnabledMark = 0;
|
||||
|
||||
// 同步删除用户 只能 该状态为 : 禁用
|
||||
return await _sqlSugarClient.Updateable(oldEntity).CallEntityMethod(m => m.LastModify()).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync() > 0;
|
||||
|
||||
}
|
||||
else if (actionType.Equals("PASSWORD_ACTION"))
|
||||
{
|
||||
return await _sqlSugarClient.Updateable<UserEntity>().SetColumns(it => new UserEntity()
|
||||
{
|
||||
Password = entity.Password,
|
||||
ChangePasswordDate = SqlFunc.GetDate(),
|
||||
LastModifyUserId = _userManager.UserId,
|
||||
LastModifyTime = SqlFunc.GetDate()
|
||||
}).Where(it => it.Id == entity.Id).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//_logger.info("Other Action , will sikp it ...");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user