OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-10-14 d680ff9fa4298ad3c0cd12f5f9d87f6c51110480
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
package kr.wisestone.owl.web.controller;
 
import com.google.common.collect.Lists;
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.constant.MsgConstants;
import kr.wisestone.owl.domain.Project;
import kr.wisestone.owl.domain.Workspace;
import kr.wisestone.owl.domain.enumType.ProjectType;
import kr.wisestone.owl.service.ProjectService;
import kr.wisestone.owl.util.ConvertUtil;
import kr.wisestone.owl.util.MapUtil;
import kr.wisestone.owl.vo.ProjectVo;
import kr.wisestone.owl.vo.WorkspaceVo;
import kr.wisestone.owl.web.condition.ProjectCondition;
import kr.wisestone.owl.web.form.ProjectForm;
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.servlet.ModelAndView;
import sun.rmi.runtime.Log;
 
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by jeong on 2017-12-30.
 */
@Controller
public class ProjectController extends BaseController {
 
    @Autowired
    private ProjectService projectService;
 
    //  프로젝트 생성
    @RequestMapping(value = "/project/add", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> add(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        Project project = this.projectService.addProject(ProjectForm.make(params.get(Constants.REQ_KEY_CONTENT)));
        resJsonData.put(Constants.RES_KEY_CONTENTS, ConvertUtil.copyProperties(project, ProjectVo.class));
        return this.setSuccessMessage(resJsonData);
    }
 
    //  프로젝트 조회
    @RequestMapping(value = "/project/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.projectService.findProject(resJsonData, ProjectCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable);
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  참여 프로젝트 조회
    @RequestMapping(value = "/project/findWork", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> findWork(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
 
        List<Map<String, Object>> projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(ProjectCondition.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        List<ProjectVo> projectVos = Lists.newArrayList();
 
        for (Map<String, Object> map : projects) {
            ProjectVo projectVo = new ProjectVo();
            projectVo.setName(MapUtil.getString(map, "name"));
            projectVo.setId(MapUtil.getLong(map, "id"));
 
            projectVos.add(projectVo);
        }
 
        resJsonData.put(Constants.RES_KEY_CONTENTS, projectVos);
        resJsonData.put(Constants.REQ_KEY_PAGE_VO, pageable);
 
        return this.setSuccessMessage(resJsonData);
    }
 
 
    //  참여 프로젝트 조회
    @RequestMapping(value = "/project/findListWork", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> findListWork(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
        Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
 
        List<ProjectVo> projectVos = this.projectService.findByIncludeProject(Lists.newArrayList("01", "02", "03"), ProjectType.BTS_PROJECT.toString());
 
        resJsonData.put(Constants.RES_KEY_CONTENTS, projectVos);
        resJsonData.put(Constants.REQ_KEY_PAGE_VO, pageable);
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  프로젝트 상세 조회
    @RequestMapping(value = "/project/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.projectService.detailProject(resJsonData, ProjectCondition.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  프로젝트 수정
    @RequestMapping(value = "/project/modify", produces = MediaType.APPLICATION_JSON_VALUE)
    public
    @ResponseBody
    Map<String, Object> modify(@RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<>();
 
        this.projectService.modifyProject(ProjectForm.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  프로젝트 삭제
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/project/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.projectService.removeProjects(ProjectForm.make(params.get(Constants.REQ_KEY_CONTENT)));
 
        return this.setSuccessMessage(resJsonData);
    }
 
    //  프로젝트 엑셀 다운로드
    @RequestMapping(value = "/project/downloadExcel", method = RequestMethod.POST)
    public ModelAndView downloadExcel(HttpServletRequest request, Model model) {
        return this.projectService.downloadExcel(request, model);
    }
 
    // 마지막으로 사용한 프로젝트 가져오기
    @RequestMapping(value = "/project/findLastUseProject", produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody Map<String, Object> findLastUseProject(
            @RequestBody Map<String, Map<String, Object>> params) {
        Map<String, Object> resJsonData = new HashMap<String, Object>();
        this.projectService.findLastUseProject(resJsonData);
 
        return this.setSuccessMessage(resJsonData);
    }
}