|
@@ -262,20 +262,72 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
@Override
|
|
|
public IPage<FileAndFolder> esSearch(SearchProjectFileDTO dto, IPage<FileAndFolder> page) {
|
|
|
IPage<FileAndFolder> res = new Page<>();
|
|
|
- Long deptId = dto.getTopDeptId();
|
|
|
+ Long topDept = dto.getTopDeptId();
|
|
|
String text = dto.getText();
|
|
|
Long projectId = dto.getProjectId();
|
|
|
Long createUser = dto.getCreateUser();
|
|
|
Set<Long> projectIds = new HashSet<>();
|
|
|
+ Set<String> proIds = new HashSet<>();
|
|
|
if (projectId != null && projectId > 0L) {
|
|
|
projectIds.add(projectId);
|
|
|
+ proIds.add(String.valueOf(projectId));
|
|
|
} else {
|
|
|
//如果projectId为空 则查询机构下所有项目
|
|
|
//此机构下的项目
|
|
|
- List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, null, AuthUtil.getUserId());
|
|
|
+ /*List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, Func.firstLong(AuthUtil.getDeptId()), null);
|
|
|
if (!CollectionUtils.isEmpty(auths)) {
|
|
|
Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
projectIds.addAll(ids);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ String role = AuthUtil.getUserRole();
|
|
|
+ Long deptId = Func.firstLong(AuthUtil.getDeptId());
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ //1.2 是服务机构
|
|
|
+ if (role != null) {
|
|
|
+ if (role.contains(STAFF_ADMIN)) {
|
|
|
+ // 1.2.1 机构管理员 ---> 项目权限表里 topDept 字段是自己的集合
|
|
|
+ List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ projectIds.addAll(ids);
|
|
|
+
|
|
|
+ Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ proIds.addAll(collect);
|
|
|
+ }
|
|
|
+ } else if (role.contains(STAFF_SECOND_ADMIN)) {
|
|
|
+ // 1.2.2 次级机构主管 ---> 项目权限表里 userDept 字段是自己的集合
|
|
|
+ List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, deptId, null);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ projectIds.addAll(ids);
|
|
|
+
|
|
|
+ Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ proIds.addAll(collect);
|
|
|
+ }
|
|
|
+ } else if (role.contains(STAFF_USER) || role.contains(STAFF_PROJECT_MANAGER)) {
|
|
|
+ //1.2.3 普通员工和项目经理 --->项目权限表里 userId 是自己的
|
|
|
+ List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(null, null, userId);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ projectIds.addAll(ids);
|
|
|
+
|
|
|
+ Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ proIds.addAll(collect);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //都不是以上角色 则只可能是业主
|
|
|
+ List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ projectIds.addAll(ids);
|
|
|
+
|
|
|
+ Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ proIds.addAll(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("查询不到您的角色信息,无法搜索资料");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -289,9 +341,9 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
BoolQueryBuilder condition = QueryBuilders.boolQuery();
|
|
|
|
|
|
//2. 添加must子句
|
|
|
- condition.must(QueryBuilders.termsQuery("projectId", projectIds));
|
|
|
+ condition.must(QueryBuilders.termsQuery("projectId", proIds));
|
|
|
if (createUser != null) {
|
|
|
- condition.must(QueryBuilders.termQuery("createUser", createUser));
|
|
|
+ condition.must(QueryBuilders.termQuery("createUser", String.valueOf(createUser)));
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(text)) {
|
|
|
// 3.添加should子句
|
|
@@ -321,7 +373,7 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
Set<Long> fileIds = set.stream().map(Document::getFileId).collect(Collectors.toSet());
|
|
|
lqw.in(FileAndFolder::getBladeFileId, fileIds);
|
|
|
res = fileAndFolderService.page(page, lqw);
|
|
|
- } else {
|
|
|
+ } else if (!CollectionUtils.isEmpty(projectIds)) {
|
|
|
LambdaQueryWrapper<FileAndFolder> lqw = new LambdaQueryWrapper<>();
|
|
|
lqw.eq(FileAndFolder::getType, 1);
|
|
|
lqw.in(FileAndFolder::getProjectId, projectIds);
|