OWL ITS + 탐지시스템(인터넷 진흥원)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package kr.wisestone.owl.web.controller;
 
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.domain.Issue;
import kr.wisestone.owl.service.IssueService;
import kr.wisestone.owl.util.ConvertUtil;
import kr.wisestone.owl.web.condition.ApiMonitorCondition;
import kr.wisestone.owl.web.condition.DepartmentCondition;
import kr.wisestone.owl.web.condition.IssueCondition;
import kr.wisestone.owl.web.form.EmailCommonForm;
import kr.wisestone.owl.web.form.EmailTemplateForm;
import kr.wisestone.owl.web.form.IssueForm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
 
/**
 * Created by wisestone on 2018-01-03.
 */
@Controller
public class IssueController extends BaseController {
 
    private static final Logger log = LoggerFactory.getLogger(IssueController.class);
 
    @Autowired
    private IssueService issueService;
 
    //  이슈 생성
    @RequestMapping(value = "/issue/add", method = RequestMethod.POST)
    public
    @ResponseBody
    Map<String, Object> add(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        //  이슈 생성
        Issue issue = this.issueService.addIssue(IssueForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
        //  버전 생성
        this.issueService.addIssueVersion(issue.getId());
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  연관이슈 생성
    @RequestMapping(value = "/issue/relIssueAdd", method = RequestMethod.POST)
    public
    @ResponseBody
    Map<String, Object> relIssueAdd(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        //  이슈 생성
        Issue issue = this.issueService.addRelIssue(IssueForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
        //  버전 생성
        this.issueService.addIssueVersion(issue.getId());
 
        resJsonData.put(Constants.RES_KEY_CONTENTS, issue.getId()); //연관이슈 ID
        return this.setSuccessMessage(resJsonData);
    }
 
    //  하위이슈 생성
    @RequestMapping(value = "/issue/downIssueAdd", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> downIssueAdd(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        //  이슈 생성
        Issue issue = this.issueService.addDownIssue(resJsonData, IssueForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
        //  버전 생성
        this.issueService.addIssueVersion(issue.getId());
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 조회
    @RequestMapping(value = "/issue/find", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> find(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
 
        this.issueService.findIssue(resJsonData, IssueCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable);
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  파트너 목록 조회
    @RequestMapping(value = "/issue/findPartner", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> findPartner(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.findPartner(resJsonData, params.get(Constants.REQ_KEY_CONTENT));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  파트너 목록 조회
    @RequestMapping(value = "/issue/findReadyDepartments", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> findReadyDepartments(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
 
        this.issueService.findReadyDepartments(resJsonData, DepartmentCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable);
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 상세 조회
    @RequestMapping(value = "/issue/detail", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> detail(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.detailIssue(resJsonData, IssueCondition.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 수정
    @RequestMapping(value = "/issue/modify", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> modify(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        //  이슈 수정
        Issue issue = this.issueService.modifyIssue(IssueForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
        //  버전 생성
        this.issueService.addIssueVersion(issue.getId());
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  하위 이슈 추가
    @RequestMapping(value = "/issue/modifyParentIssue", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> modifyParentIssue(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.modifyParentIssue(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 삭제
    @RequestMapping(value = "/issue/remove", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> removes(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.removeIssues(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  하위이슈 삭제
    @RequestMapping(value = "/issue/removeAll", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> removesAll(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.removeAllIssues(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  하위이슈 삭제
    /*@RequestMapping(value = "/issue/removeDown", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> removesDown(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.removeDownIssues(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }*/
 
    //  이슈 다중 상태 변경
    @RequestMapping(value = "/issue/modifyMultiIssueStatus", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> modifyMultiIssueStatus(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.modifyMultiIssueStatus(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 엑셀 다운로드
    @RequestMapping(value = "/issue/downloadExcel", method = RequestMethod.POST)
    public ModelAndView downloadExcel(HttpServletRequest request, Model model) {
        return this.issueService.downloadExcel(request, model);
    }
 
    //  이슈 Import 용 엑셀 템플릿 다운로드
    @RequestMapping(value = "/issue/downloadExcelTemplate", method = RequestMethod.POST)
    public ModelAndView downloadExcelImport(HttpServletRequest request, Model model) {
        return this.issueService.downloadExcelTemplate(request, model);
    }
 
    //  이슈 엑셀 등록
    @RequestMapping(value = "/issue/importExcel", method = RequestMethod.POST)
    public @ResponseBody Map<String, Object> importExcel(MultipartHttpServletRequest request) throws Exception {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.issueService.importExcel(IssueForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFile("file"));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 메일 발송
    @RequestMapping(value = "/issue/sendEmail", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> sendEmail(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.sendIssueEmail(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 메일 파트너 담당자에게 발송 (템플릿 추가)
    @RequestMapping(value = "/issue/sendEmailPartners", method = RequestMethod.POST)
    public
    @ResponseBody
    Map<String, Object> sendEmailPartners(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.sendIssueEmailPartners(EmailTemplateForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
//        this.issueService.sendIssueEmailPartners(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT)));
        return this.setSuccessMessage(resJsonData);
    }
 
 
    // 일반 메일 발송 (사용자 직접 작성)
    @RequestMapping(value = "/issue/sendCommonEmail", method = RequestMethod.POST)
    public
    @ResponseBody
    Map<String, Object> sendCommonEmail(MultipartHttpServletRequest request) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.sendCommonEmail(EmailCommonForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFiles("file"));
        return this.setSuccessMessage(resJsonData);
    }
 
    //  api 기록 조회
    @RequestMapping(value = "/api/findHistory", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> findApiHistory(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        this.issueService.findApiIssue(ApiMonitorCondition.make(params.get(Constants.REQ_KEY_CONTENT)), resJsonData);
        return this.setSuccessMessage(resJsonData);
    }
}