v3.4.6
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user