| | |
| | | private SimpMessagingTemplate simpMessagingTemplate; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | |
| | | @Autowired |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user)) { |
| | | if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user, null)) { |
| | | issueVo.setModifyPermissionCheck(Boolean.TRUE); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user)) { |
| | | if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user, issueVo.getDepartmentVos())) { |
| | | issueVo.setModifyPermissionCheck(Boolean.TRUE); |
| | | } |
| | | } |
| | |
| | | DepartmentVo departmentVo = ConvertUtil.copyProperties(issueDepartment.getDepartment(), DepartmentVo.class); |
| | | departmentVo.setByName(departmentVo.getDepartmentName()); |
| | | departmentVos.add(departmentVo); |
| | | |
| | | List<UserDepartment> userDepartments = this.userDepartmentRepository.findByDepartmentId(departmentVo.getId()); |
| | | if (userDepartments != null && userDepartments.size() > 0) { |
| | | for (UserDepartment userDepartment : userDepartments) { |
| | | if (userDepartment.getUserId().equals(this.webAppUtil.getLoginId())){ |
| | | issueVo.setModifyPermissionCheck(Boolean.TRUE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | issueVo.setDepartmentVos(departmentVos); |
| | | } |
| | |
| | | // 이슈 수정 권한 체크 |
| | | private void verifyIssueModifyPermission(Issue issue, User user) { |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | if (!this.checkHasPermission(ConvertUtil.copyProperties(issue, IssueVo.class), this.getIssueUserVos(issue), user)) { |
| | | if (!this.checkHasPermission(ConvertUtil.copyProperties(issue, IssueVo.class), this.getIssueUserVos(issue), user, this.getIssueDepartmentVos(issue))) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_MODIFY_PERMISSION)); |
| | | } |
| | |
| | | return userVos; |
| | | } |
| | | |
| | | // 이슈에서 담당자 정보를 추출한다. |
| | | private List<DepartmentVo> getIssueDepartmentVos(Issue issue) { |
| | | List<DepartmentVo> departmentVos = Lists.newArrayList(); |
| | | |
| | | Set<IssueDepartment> issueDepartments = issue.getIssueDepartments(); |
| | | |
| | | try { |
| | | for (IssueDepartment issueDepartment : issueDepartments) { |
| | | Department department = issueDepartment.getDepartment(); |
| | | DepartmentVo departmentVo = ConvertUtil.copyProperties(department, DepartmentVo.class); |
| | | departmentVos.add(departmentVo); |
| | | } |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | |
| | | return departmentVos; |
| | | } |
| | | |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | private boolean checkHasPermission(IssueVo issueVo, List<UserVo> issueUserVos, User user) { |
| | | private boolean checkHasPermission(IssueVo issueVo, List<UserVo> issueUserVos, User user, List<DepartmentVo> departmentVos) { |
| | | boolean hasPermission = false; |
| | | |
| | | // 업무 공간 관리자일 경우 수정 권한을 갖는다. |
| | |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.PROJECT_MANAGER, issueVo, null, null, user); |
| | | // 이슈 등록자일 경우 수정 권한을 갖는다. |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.REGISTER, issueVo, null, null, user); |
| | | // 이슈 담당자일 경우 수정 권한을 갖는다. => 담당부서로 수정 - 체크 |
| | | // 이슈 담당자일 경우 수정 권한을 갖는다. |
| | | //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos); |
| | | // 이슈 담당부서일 경우 수정 권한을 갖는다. |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.DEPARTMENT, issueVo, null, departmentVos, user); |
| | | // 담당자가 없으면 모든 사용자가 수정 권한을 갖는다. |
| | | |
| | | //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_ISSUE_MANAGER, issueVo, null, null, user); |
| | |
| | | } |
| | | |
| | | // 이슈 수정 권한을 확인한다. |
| | | private boolean checkIssueModifyPermission(Boolean hasPermission, String checkType, IssueVo issueVo, List<UserVo> issueUserVos, List<DepartmentVo> issueDepartmentVos, User user) { |
| | | private boolean checkIssueModifyPermission(Boolean hasPermission, String checkType, IssueVo issueVo, List<UserVo> issueUserVos, List<DepartmentVo> departmentVos, User user) { |
| | | if (!hasPermission) { |
| | | switch (checkType) { |
| | | case Issue.WORKSPACE_MANAGER: // 업무 공간 관리자 |
| | |
| | | |
| | | case Issue.DEPARTMENT: |
| | | // 담당부서가 없으면 모든 사용자가 수정 권한을 갖는다. |
| | | if (issueDepartmentVos.size() < 1) { |
| | | /*if (userDepartmentVos.size() < 1) { |
| | | hasPermission = true; |
| | | break; |
| | | } |
| | | // 이슈 담당부서 여부 확인 |
| | | /*for (DepartmentVo issueDepartmentVo : issueDepartmentVos) { |
| | | if (issueDepartmentVo.getId().equals()) { |
| | | hasPermission = true; |
| | | break; |
| | | } |
| | | }*/ |
| | | // 이슈 담당부서 여부 확인 |
| | | for (DepartmentVo departmentVo : departmentVos) { |
| | | List<UserDepartment> userDepartments = this.userDepartmentService.findByDepartmentId(departmentVo.getId()); |
| | | if(userDepartments != null && userDepartments.size() > 0) { |
| | | for (UserDepartment userDepartment : userDepartments) { |
| | | if (userDepartment.getUserId().equals(user.getId())){ |
| | | hasPermission = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |