Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1414,12 +1414,69 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient
|
|||||||
// 用户信息列表
|
// 用户信息列表
|
||||||
List<UserListImportDataInput>? userList = new List<UserListImportDataInput>();
|
List<UserListImportDataInput>? userList = new List<UserListImportDataInput>();
|
||||||
|
|
||||||
ISugarQueryable<UserListImportDataInput>? sqlQuery = _repository.AsSugarClient().Queryable<UserEntity, OrganizeEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == SqlFunc.ToString(a.OrganizeId)))
|
// 获取分级管理组织
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(input.organizeId), a => a.OrganizeId == input.organizeId) // 组织机构
|
var dataScope = _userManager.DataScope.Where(x => x.Select).Select(x => x.organizeId).Distinct().ToList();
|
||||||
.WhereIF(!input.keyword.IsNullOrEmpty(), a => a.Account.Contains(input.keyword) || a.RealName.Contains(input.keyword))
|
|
||||||
.Where(a => a.DeleteMark == null)
|
#region 获取组织层级
|
||||||
.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
|
||||||
.Select(a => new UserListImportDataInput()
|
List<string>? childOrgIds = new List<string>();
|
||||||
|
if (input.organizeId.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
childOrgIds.Add(input.organizeId);
|
||||||
|
|
||||||
|
// 根据组织Id 获取所有子组织Id集合
|
||||||
|
childOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().ToChildList(x => x.ParentId, input.organizeId).Select(x => x.Id).ToList());
|
||||||
|
childOrgIds = childOrgIds.Distinct().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 老代码
|
||||||
|
//ISugarQueryable<UserListImportDataInput>? sqlQuery = _repository.AsSugarClient().Queryable<UserEntity, OrganizeEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == SqlFunc.ToString(a.OrganizeId)))
|
||||||
|
// .WhereIF(!string.IsNullOrWhiteSpace(input.organizeId), a => a.OrganizeId == input.organizeId) // 组织机构
|
||||||
|
// .WhereIF(!input.keyword.IsNullOrEmpty(), a => a.Account.Contains(input.keyword) || a.RealName.Contains(input.keyword))
|
||||||
|
// .Where(a => a.DeleteMark == null)
|
||||||
|
// .OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||||
|
// .Select(a => new UserListImportDataInput()
|
||||||
|
// {
|
||||||
|
// id = a.Id,
|
||||||
|
// account = a.Account,
|
||||||
|
// realName = a.RealName,
|
||||||
|
// birthday = SqlFunc.ToString(a.Birthday),
|
||||||
|
// certificatesNumber = a.CertificatesNumber,
|
||||||
|
// managerId = SqlFunc.Subqueryable<UserEntity>().Where(e => e.Id == a.ManagerId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||||
|
// organizeId = a.OrganizeId, // 组织结构
|
||||||
|
// positionId = a.PositionId, // 岗位
|
||||||
|
// roleId = a.RoleId, // 多角色
|
||||||
|
// certificatesType = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.DictionaryTypeId == "7866376d5f694d4d851c7164bd00ebfc" && d.Id == a.CertificatesType).Select(b => b.FullName),
|
||||||
|
// education = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.DictionaryTypeId == "6a6d6fb541b742fbae7e8888528baa16" && d.Id == a.Education).Select(b => b.FullName),
|
||||||
|
// gender = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.DictionaryTypeId == "963255a34ea64a2584c5d1ba269c1fe6" && d.EnCode == SqlFunc.ToString(a.Gender)).Select(b => b.FullName),
|
||||||
|
// nation = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.DictionaryTypeId == "b6cd65a763fa45eb9fe98e5057693e40" && d.Id == a.Nation).Select(b => b.FullName),
|
||||||
|
// description = a.Description,
|
||||||
|
// entryDate = SqlFunc.ToString(a.EntryDate),
|
||||||
|
// email = a.Email,
|
||||||
|
// enabledMark = SqlFunc.IF(a.EnabledMark.Equals(0)).Return("禁用").ElseIF(a.EnabledMark.Equals(1)).Return("正常").End("锁定"),
|
||||||
|
// mobilePhone = a.MobilePhone,
|
||||||
|
// nativePlace = a.NativePlace,
|
||||||
|
// postalAddress = a.PostalAddress,
|
||||||
|
// telePhone = a.TelePhone,
|
||||||
|
// urgentContacts = a.UrgentContacts,
|
||||||
|
// urgentTelePhone = a.UrgentTelePhone,
|
||||||
|
// landline = a.Landline,
|
||||||
|
// sortCode = a.SortCode.ToString()
|
||||||
|
// });
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
ISugarQueryable<UserListImportDataInput>? sqlQuery = _repository.AsSugarClient().Queryable<UserEntity, UserRelationEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.UserId == a.Id))
|
||||||
|
.Where((a, b) => a.DeleteMark == null && !a.Account.Equals("admin"))
|
||||||
|
.WhereIF(childOrgIds.Any(), (a, b) => childOrgIds.Contains(b.ObjectId))
|
||||||
|
.WhereIF(!input.keyword.IsNullOrEmpty(), (a, b) => a.Account.Contains(input.keyword) || a.RealName.Contains(input.keyword))
|
||||||
|
.WhereIF(!_userManager.IsAdministrator, (a, b) => dataScope.Contains(b.ObjectId))
|
||||||
|
.OrderBy((a, b) => a.SortCode).OrderBy((a, b) => a.CreatorTime, OrderByType.Desc).OrderBy((a, b) => a.LastModifyTime, OrderByType.Desc)
|
||||||
|
.GroupBy((a, b) => new { a.Id, a.Account, a.RealName, a.CreatorTime, a.LastModifyTime, a.Gender, a.MobilePhone, a.SortCode, a.EnabledMark, a.UnLockTime })
|
||||||
|
//.OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc)
|
||||||
|
.Select((a, b) => new UserListImportDataInput()
|
||||||
{
|
{
|
||||||
id = a.Id,
|
id = a.Id,
|
||||||
account = a.Account,
|
account = a.Account,
|
||||||
|
|||||||
Reference in New Issue
Block a user