OWL ITS + 탐지시스템(인터넷 진흥원)
wyu
2021-11-23 e35b0c987bac49abbb77d4b31e41270cc566e54d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package kr.wisestone.owl.service.impl;
 
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.domain.*;
import kr.wisestone.owl.repository.IssueTableConfigRepository;
import kr.wisestone.owl.service.IssueService;
import kr.wisestone.owl.service.IssueTableConfigService;
import kr.wisestone.owl.service.UserService;
import kr.wisestone.owl.service.WorkspaceService;
import kr.wisestone.owl.util.ConvertUtil;
import kr.wisestone.owl.util.MapUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Map;
 
@Service
public class IssueTableConfigServiceImpl extends AbstractServiceImpl<IssueTableConfig, Long, JpaRepository<IssueTableConfig, Long>> implements IssueTableConfigService {
 
    private static final Logger log = LoggerFactory.getLogger(IssueTableConfigServiceImpl.class);
 
    @Autowired
    private IssueTableConfigRepository issueTableConfigRepository;
 
    @Autowired
    private WorkspaceService workspaceService;
 
    @Autowired
    private UserService userService;
 
    @Override
    protected JpaRepository<IssueTableConfig, Long> getRepository() {
        return this.issueTableConfigRepository;
    }
 
    Long issueId;
    int issueTableType = 0; //issueTableType 초기값 설정
 
    //  add 중복코드 제거
    public IssueTableConfig addMultipleCode(Map<String, Object> params, Long issueId, int issueTableType) {
        String issueTableConfigs = MapUtil.getString(params, "issueTableConfigs");
        IssueTableConfig issueTableConfig = this.findByUserIdAndWorkspaceIdAndIssueIdAndIssueTableType(issueId, issueTableType);
        //IssueTableConfig saveIssueTableType = this.findByIssueIdAndIssueTableType(issueId,issueTableType);
 
        //  아직 테이블 컬럼 설정을 하지 않았을 경우
        if (issueTableConfig == null) {
            issueTableConfig = new IssueTableConfig();
            Workspace workspace = this.workspaceService.getWorkspace(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
            User user = this.userService.getUser(this.webAppUtil.getLoginId());
            issueTableConfig.setWorkspace(workspace);
            issueTableConfig.setUser(user);
            issueTableConfig.setIssueId(issueId);
            issueTableConfig.setIssueTableType(issueTableType);
            issueTableConfig.setIssueTableConfigs(issueTableConfigs);
        /*}else if(saveIssueTableType == null){
            issueTableConfig = new IssueTableConfig();
            Workspace workspace = this.workspaceService.getWorkspace(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
            User user = this.userService.getUser(this.webAppUtil.getLoginId());
            issueTableConfig.setWorkspace(workspace);
            issueTableConfig.setUser(user);
            issueTableConfig.setIssueId(issueId);
            issueTableConfig.setIssueTableType(issueTableType);
            issueTableConfig.setIssueTableConfigs(issueTableConfigs);*/
        }else {
            issueTableConfig.setIssueTableConfigs(issueTableConfigs);
        }
        return this.issueTableConfigRepository.saveAndFlush(issueTableConfig);
    }
 
    //  이슈 테이블 컬럼 설정 정보를 저장한다.
    @Override
    @Transactional
    public IssueTableConfig addIssueTableConfig(Map<String, Object> params) {
        issueId = (long) -1;
        issueTableType = 1;
        return this.addMultipleCode(params, issueId, issueTableType);
    }
    // 연관 이슈 테이블 설정 정보 저장
    @Override
    public IssueTableConfig addRelationIssueTableConfig(Map<String, Object> params) {
        issueId = MapUtil.getLong(params, "issueId");
        issueTableType = 2;
        return this.addMultipleCode(params, issueId, issueTableType);
    }
    // 하위 이슈 테이블 설정 정보 저장
    @Override
    public IssueTableConfig addDownIssueTableConfig(Map<String, Object> params) {
        issueId = MapUtil.getLong(params, "issueId");
        issueTableType = 3;
        return this.addMultipleCode(params, issueId, issueTableType);
    }
 
    //  해당 업무 공간에서 사용자의 이슈 테이블 설정을 조회한다.
    @Override
    @Transactional(readOnly = true)
    public IssueTableConfig findByUserIdAndWorkspaceIdAndIssueIdAndIssueTableType(Long issueId, int issueTableType) {
        return this.issueTableConfigRepository.findByUserIdAndWorkspaceIdAndIssueIdAndIssueTableType(this.webAppUtil.getLoginId(),
                this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId(), issueId, issueTableType);
    }
 
    //이슈 Id와 IssueTableType 조회
    @Override
    @Transactional(readOnly = true)
    public IssueTableConfig findByIssueIdAndIssueTableType(Long issueId, int issueTableType) {
        return this.issueTableConfigRepository.findByIssueIdAndIssueTableType(issueId, issueTableType);
    }
 
    // detail 중복 코드 제거
    private void detailMultipleCode(Map<String, Object> resJsonData, Long issueId, int issueTableType) {
        //  해당 업무 공간에서 사용자의 이슈 검색 조건을 조회한다.
        IssueTableConfig issueTableConfig = this.findByUserIdAndWorkspaceIdAndIssueIdAndIssueTableType(issueId, issueTableType);
 
        if (issueTableConfig != null) {
            resJsonData.put(Constants.RES_KEY_CONTENTS, issueTableConfig.getIssueTableConfigs());
        }
        else {
            resJsonData.put(Constants.RES_KEY_CONTENTS, "");
        }
    }
 
    //  저장된 이슈 테이블 설정을 조회한다.
    @Override
    @Transactional(readOnly = true)
    public void detailIssueTableConfig(Map<String, Object> resJsonData) {
        issueId = (long) -1;
        issueTableType = 1;
        //  해당 업무 공간에서 사용자의 이슈 검색 조건을 조회한다.
        IssueTableConfig issueTableConfig = this.findByUserIdAndWorkspaceIdAndIssueIdAndIssueTableType(issueId, issueTableType);
 
        if (issueTableConfig != null) {
            resJsonData.put(Constants.RES_KEY_CONTENTS, issueTableConfig.getIssueTableConfigs());
        }
        else {
            resJsonData.put(Constants.RES_KEY_CONTENTS, "");
        }
    }
    //  저장된 연관 이슈 테이블 설정 조회
    @Override
    public void detailRelationIssueTableConfig(Map<String, Object> params, Map<String, Object> resJsonData) {
        issueTableType = 2;
        issueId = MapUtil.getLong(params, "issueId");
        this.detailMultipleCode(resJsonData, issueId, issueTableType);
    }
    //  저장된 하위 이슈 테이블 설정 조회
    @Override
    public void detailDownIssueTableConfig(Map<String, Object> params, Map<String, Object> resJsonData) {
        issueTableType = 3;
        issueId = MapUtil.getLong(params, "issueId");
        this.detailMultipleCode(resJsonData, issueId, issueTableType);
    }
 
 
 
}