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);
|
}
|
}
|