|
@@ -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 {
|
|
|
|
|
|
|
|
|
- List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, null, AuthUtil.getUserId());
|
|
|
+
|
|
|
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();
|
|
|
+
|
|
|
+ if (role != null) {
|
|
|
+ if (role.contains(STAFF_ADMIN)) {
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+
|
|
|
+ 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();
|
|
|
|
|
|
|
|
|
- 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)) {
|
|
|
|
|
@@ -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);
|