OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2021-12-10 3bdf2a1f2757de8ab6570508385d89124243943c
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -151,6 +151,9 @@
    private UserWorkspaceService userWorkspaceService;
    @Autowired
    private UserLevelService userLevelService;
    @Autowired
    private WorkflowDepartmentService workflowDepartmentService;
    @Autowired
@@ -715,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,8 +748,10 @@
        List<Map<String, Object>> results = Lists.newArrayList();
        Long totalCount = 0L;
        UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
        if (this.userWorkspaceService.checkWorkspaceManager(user) || user.getPermission() >= MngPermission.USER_PERMISSION_MNG_ISSUE_ALL) {
        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{
@@ -1033,6 +1038,7 @@
        condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
        projectCondition.setWorkspaceId(condition.getWorkspaceId());
        //  프로젝트 키가 존재할 경우 프로젝트 키에 해당하는 프로젝트를 조회하고 검색 조건에 셋팅한다.
        if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) {
            return false;
@@ -1041,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);
@@ -2155,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;
    }