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.service.impl.IssueServiceImpl;
|
import kr.wisestone.owl.util.ConvertUtil;
|
import kr.wisestone.owl.web.condition.IssueCondition;
|
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/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/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/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(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);
|
}
|
|
|
}
|