OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-12-01 a42f592181c23cb1d84d5b66b4b165aa855d57e2
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
package kr.wisestone.owl.web.controller;
 
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.domain.Issue;
import kr.wisestone.owl.service.GuideService;
import kr.wisestone.owl.service.IssueService;
import kr.wisestone.owl.util.ConvertUtil;
import kr.wisestone.owl.util.MapUtil;
import kr.wisestone.owl.web.condition.GuideCondition;
import kr.wisestone.owl.web.form.GuideForm;
import kr.wisestone.owl.web.form.IssueApiForm;
import kr.wisestone.owl.web.form.IssueForm;
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.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 java.util.HashMap;
import java.util.Map;
 
@Controller
public class ApiController extends BaseController {
 
    @Autowired
    private IssueService issueService;
 
    //  이슈 추가(json 방식으로 파일전송)
//    @RequestMapping(value = "api/issue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
//    public
//    @ResponseBody
//    Map<String, Object> addIssue(@RequestBody Map<String, Map<String, Object>> params) {
//        Map<String, Object> resJsonData = new HashMap<>();
//
//        IssueApiForm issueForm = IssueApiForm.make(params.get(Constants.REQ_KEY_CONTENT));
//        Issue issue = this.issueService.addApiIssue(issueForm);
//        //  버전 생성
//        this.issueService.addIssueVersion(issue.getId());
//        return this.setSuccessMessage(resJsonData);
//    }
    @RequestMapping(value = "api/issue", method = RequestMethod.POST)
    public
    @ResponseBody
    Map<String, Object> addIssue(MultipartHttpServletRequest request) throws Exception {
        Map<String, Object> resJsonData = new HashMap<>();
 
        IssueApiForm issueForm = IssueApiForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT)), request.getFiles("file"));
        Issue issue = this.issueService.addApiIssue(issueForm);
        //  버전 생성
        this.issueService.addIssueVersion(issue.getId());
        return this.setSuccessMessage(resJsonData);
    }
 
    //  이슈 조회
    @RequestMapping(value = "/api/issueList", method = RequestMethod.GET, 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));
 
        // todo
 
        return this.setSuccessMessage(resJsonData);
    }
}