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 add(MultipartHttpServletRequest request) { Map 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 find(@RequestBody Map> params) { Map 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 findPartner(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.issueService.findPartner(resJsonData, params.get(Constants.REQ_KEY_CONTENT)); return this.setSuccessMessage(resJsonData); } // 이슈 상세 조회 @RequestMapping(value = "/issue/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map detail(@RequestBody Map> params) { Map 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 modify(MultipartHttpServletRequest request) { Map 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 modifyParentIssue(@RequestBody Map> params) { Map 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 removes(@RequestBody Map> params) { Map 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 modifyMultiIssueStatus(@RequestBody Map> params) { Map 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 importExcel(MultipartHttpServletRequest request) throws Exception { Map 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 sendEmail(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.issueService.sendIssueEmail(IssueForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 메일 발송 대상자 목록 조회 /*@RequestMapping(value = "/issue/findMailTargetAll", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map findMailTargetAll(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params)); this.issueService.findMailTargetAll(resJsonData, IssueCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable); return this.setSuccessMessage(resJsonData); }*/ /*// 업체 담당자 메일 목록 조회 @RequestMapping(value = "/issue/findMailTargetCompany", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map findMailTargetCompany(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.issueService.findMailTargetCompany(resJsonData, params.get(Constants.REQ_KEY_CONTENT)); return this.setSuccessMessage(resJsonData); } // ISP 담당자 메일 목록 조회 @RequestMapping(value = "/issue/findMailTargetIsp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map findMailTargetIsp(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.issueService.findMailTargetIsp(resJsonData, params.get(Constants.REQ_KEY_CONTENT)); return this.setSuccessMessage(resJsonData); } // 호스팅 담당자 메일 목록 조회 @RequestMapping(value = "/issue/findMailTargetHosting", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map findMailTargetHosting(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.issueService.findMailTargetHosting(resJsonData, params.get(Constants.REQ_KEY_CONTENT)); return this.setSuccessMessage(resJsonData); }*/ }