260803_03_ENH: 연구는 자기 부서 프로젝트만 보이게 수정 #12
@@ -19,6 +19,7 @@ public final class ContactConstant {
|
||||
public static final String DEFAULT_USER_TEAM = "S101";
|
||||
public static final String DEFAULT_CALLER_TELNUM = "0234155100";
|
||||
|
||||
public static final int RESEARCHER_USER_ROLE = 2000;
|
||||
public static final int OUTSOURCE_USER_ROLE = 4000;
|
||||
public static final int FIELDWORK_USER_ROLE = 9000;
|
||||
public static final int CONTACT_INTERVIEWER_ROLE = 9002;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ProjectController {
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return projectService.getTopProject(topCount, keyword, ctx.getUserId(), ctx.getUserCmpn(),
|
||||
ctx.getUserRole());
|
||||
ctx.getUserTeam(), ctx.getUserRole());
|
||||
}
|
||||
|
||||
@Operation(summary = "프로젝트 목록 조회")
|
||||
@@ -64,7 +64,8 @@ public class ProjectController {
|
||||
@Valid @RequestBody ProjectSearchRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserCmpn(), ctx.getUserRole());
|
||||
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserCmpn(), ctx.getUserTeam(),
|
||||
ctx.getUserRole());
|
||||
}
|
||||
|
||||
@Operation(summary = "프로젝트를 소유하고 있는 모든 부서/실사 목록 조회")
|
||||
|
||||
@@ -47,6 +47,15 @@ public class ProjectSpecs {
|
||||
};
|
||||
}
|
||||
|
||||
public static Specification<TPrjctEntity> ownerDeptEqual(String ownerDept) {
|
||||
return (root, query, cb) -> {
|
||||
if (!StringUtils.hasText(ownerDept)) {
|
||||
return cb.disjunction();
|
||||
}
|
||||
return cb.equal(root.get("ownerDept"), ownerDept.trim());
|
||||
};
|
||||
}
|
||||
|
||||
public static Specification<TPrjctEntity> ownerFwIn(List<String> list) {
|
||||
return (root, query, cb) -> {
|
||||
if (list == null || list.isEmpty()) {
|
||||
|
||||
@@ -97,12 +97,15 @@ public class ProjectService {
|
||||
String keyword,
|
||||
String userId,
|
||||
String userCmpn,
|
||||
String userTeam,
|
||||
Integer userRole
|
||||
) {
|
||||
Specification<TPrjctEntity> spec = ProjectSpecs.keywordLike(keyword)
|
||||
.and(ProjectSpecs.isDelFalse());
|
||||
|
||||
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
|
||||
if (isTeamUserRole(userRole)) {
|
||||
spec = spec.and(ProjectSpecs.ownerDeptEqual(userTeam));
|
||||
} else if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
|
||||
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
|
||||
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
|
||||
} else {
|
||||
@@ -122,6 +125,7 @@ public class ProjectService {
|
||||
ProjectSearchRequestDto req,
|
||||
String userId,
|
||||
String userCmpn,
|
||||
String userTeam,
|
||||
Integer userRole
|
||||
) {
|
||||
Specification<TPrjctEntity> spec = ProjectSpecs.keywordLike(req.getPrjctText())
|
||||
@@ -130,7 +134,9 @@ public class ProjectService {
|
||||
.and(ProjectSpecs.ownerDeptIn(req.getOwnerDeptList()))
|
||||
.and(ProjectSpecs.ownerFwIn(req.getOwnerFwList()));
|
||||
|
||||
if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
|
||||
if (isTeamUserRole(userRole)) {
|
||||
spec = spec.and(ProjectSpecs.ownerDeptEqual(userTeam));
|
||||
} else if (userRole >= ContactConstant.OUTSOURCE_USER_ROLE) {
|
||||
if (userRole >= ContactConstant.FIELDWORK_USER_ROLE) {
|
||||
spec = spec.and(ProjectSpecs.statusIn(STATUS_1));
|
||||
} else {
|
||||
@@ -405,6 +411,12 @@ public class ProjectService {
|
||||
private record ResolvedSurveyUrl(String finalUrl, String fullUrl, String shortUrl) {
|
||||
}
|
||||
|
||||
private boolean isTeamUserRole(Integer userRole) {
|
||||
return userRole != null
|
||||
&& userRole >= ContactConstant.RESEARCHER_USER_ROLE
|
||||
&& userRole < ContactConstant.RESEARCHER_USER_ROLE + 1000;
|
||||
}
|
||||
|
||||
private String makePrjctCd(String itrntPrjctCd) {
|
||||
String prefix = itrntPrjctCd + "_";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user