OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2021-12-10 3bdf2a1f2757de8ab6570508385d89124243943c
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -5,10 +5,7 @@
import kr.wisestone.owl.common.ExcelConditionCheck;
import kr.wisestone.owl.common.IssueCustomFieldValueFormComparator;
import kr.wisestone.owl.config.CommonConfiguration;
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.constant.ElasticSearchConstants;
import kr.wisestone.owl.constant.MsgConstants;
import kr.wisestone.owl.constant.UsePartner;
import kr.wisestone.owl.constant.*;
import kr.wisestone.owl.data.CheckIssueData;
import kr.wisestone.owl.domain.*;
import kr.wisestone.owl.domain.enumType.CustomFieldType;
@@ -152,6 +149,9 @@
    @Autowired
    private UserWorkspaceService userWorkspaceService;
    @Autowired
    private UserLevelService userLevelService;
    @Autowired
    private WorkflowDepartmentService workflowDepartmentService;
@@ -718,11 +718,11 @@
    public List<IssueVo> findIssue(Map<String, Object> resJsonData, IssueCondition issueCondition, Pageable pageable) {
        //  검색 조건을 만든다
        if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) {
        /*if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) {
            //  이슈 목록을 찾지 못할 경우 기본 정보로 리턴한다.
            this.notFoundIssueList(resJsonData, pageable);
            return Lists.newArrayList();
        }
        }*/
        Set<String> issueIds = new HashSet<>(); //  사용자 정의 필드 검색시 나오는 이슈 아이디 저장 컬렉션
@@ -745,10 +745,13 @@
        issueCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
        User user = this.webAppUtil.getLoginUserObject();
        List<Map<String, Object>> results = Lists.newArrayList();
        Long totalCount = 0L;
        UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
        if (this.userWorkspaceService.checkWorkspaceManager(user)) {
        if (this.userWorkspaceService.checkWorkspaceManager(user)
                || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) {
            results = this.issueMapper.find(issueCondition);
            totalCount = this.issueMapper.count(issueCondition);
        } else{
@@ -1035,6 +1038,7 @@
        condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
        projectCondition.setWorkspaceId(condition.getWorkspaceId());
        //  프로젝트 키가 존재할 경우 프로젝트 키에 해당하는 프로젝트를 조회하고 검색 조건에 셋팅한다.
        if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) {
            return false;
@@ -1043,7 +1047,9 @@
        //  프로젝트를 선택하지 않았으면 해당 업무 공간에서 참여하고 있는 프로젝트를 찾는다.
        if (condition.getProjectIds().size() < 1) {
            List<Map<String, Object>> projects = null;
            if (this.userWorkspaceService.checkWorkspaceManager(user)) {
            UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
            if (this.userWorkspaceService.checkWorkspaceManager(user)
                    || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) {
                projects = this.projectMapper.findByWorkspaceManagerAll(projectCondition);
            } else  {
                projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectCondition);
@@ -1873,6 +1879,9 @@
        //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos);
        //  담당자가 없으면 모든 사용자가 수정 권한을 갖는다.
        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_ISSUE_MANAGER, issueVo, null, null, user);
        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_PROJECT_MANAGER, issueVo, null, null, user);
        return hasPermission;
    }
@@ -2154,39 +2163,38 @@
    }
    private Issue issueRemoves(Long issueId, User user) {
        Issue issue = null;
        if(issueId != null){
            issue = this.getIssue(issueId);
        }
        //  이슈 수정 권한을 갖고 있는지 확인
        this.verifyIssueModifyPermission(issue, user);
        Issue issue = this.findOne(issueId);
        if(issue != null){
            //  이슈 수정 권한을 갖고 있는지 확인
            this.verifyIssueModifyPermission(issue, user);
        //  이슈 첨부 파일을 삭제한다.
        if (issue.getAttachedFiles().size() > 0) {
            List<Long> attachedFileIds = Lists.newArrayList();
            //  이슈 첨부 파일을 삭제한다.
            if (issue.getAttachedFiles().size() > 0) {
                List<Long> attachedFileIds = Lists.newArrayList();
            for (AttachedFile attachedFile : issue.getAttachedFiles()) {
                attachedFileIds.add(attachedFile.getId());
                for (AttachedFile attachedFile : issue.getAttachedFiles()) {
                    attachedFileIds.add(attachedFile.getId());
                }
                //  첨부파일 삭제
                this.attachedFileService.removeAttachedFiles(attachedFileIds);
            }
            //  첨부파일 삭제
            this.attachedFileService.removeAttachedFiles(attachedFileIds);
        }
        // 지울 이슈가 연관이슈인지 체크 후 연관이슈 테이블에서도 삭제한다.
        List<IssueRelation> issueRelationList = this.issueRelationRepository.findByRelationIssueId(issueId);
        if (issueRelationList != null && issueRelationList.size() > 0) {
            for(IssueRelation issueRelation : issueRelationList){
                StringBuilder sb = new StringBuilder();
                issueHistoryService.detectRelationIssue(IssueHistoryType.DELETE, issueRelation, sb);
                issueHistoryService.addIssueHistory(issueRelation.getIssue(), IssueHistoryType.MODIFY, sb.toString());
                this.issueRelationRepository.delete(issueRelation);
            // 지울 이슈가 연관이슈인지 체크 후 연관이슈 테이블에서도 삭제한다.
            List<IssueRelation> issueRelationList = this.issueRelationRepository.findByRelationIssueId(issueId);
            if (issueRelationList != null && issueRelationList.size() > 0) {
                for(IssueRelation issueRelation : issueRelationList){
                    StringBuilder sb = new StringBuilder();
                    issueHistoryService.detectRelationIssue(IssueHistoryType.DELETE, issueRelation, sb);
                    issueHistoryService.addIssueHistory(issueRelation.getIssue(), IssueHistoryType.MODIFY, sb.toString());
                    this.issueRelationRepository.delete(issueRelation);
                }
            }
        }
        //  이슈 생성, 삭제시 예약 이메일에 등록해놓는다.
        this.reservationIssueEmail(issue, EmailType.ISSUE_REMOVE);
        //  이슈 삭제
        this.issueRepository.delete(issue);
            //  이슈 생성, 삭제시 예약 이메일에 등록해놓는다.
            this.reservationIssueEmail(issue, EmailType.ISSUE_REMOVE);
            //  이슈 삭제
            this.issueRepository.delete(issue);
        }
        return issue;
    }