package kr.wisestone.owl.web.controller; import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.service.DepartmentService; import kr.wisestone.owl.service.UserDepartmentService; import kr.wisestone.owl.service.WorkflowService; import kr.wisestone.owl.util.ConvertUtil; import kr.wisestone.owl.vo.AttachedFileVo; import kr.wisestone.owl.web.condition.DepartmentCondition; import kr.wisestone.owl.web.condition.WorkflowCondition; import kr.wisestone.owl.web.form.WorkflowForm; 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-05-10. */ @Controller public class WorkflowController extends BaseController { @Autowired private WorkflowService workflowService; @Autowired private DepartmentService departmentService; // 워크플로우 생성 @RequestMapping(value = "/workflow/add", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map add(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.workflowService.addWorkflow(WorkflowForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 워크플로우 조회 @RequestMapping(value = "/workflow/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.workflowService.findWorkflow(resJsonData, WorkflowCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable); return this.setSuccessMessage(resJsonData); } // 워크플로우 상세 조회 @RequestMapping(value = "/workflow/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map detail(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.workflowService.detailWorkflow(resJsonData, WorkflowCondition.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 워크플로우 수정 @RequestMapping(value = "/workflow/modify", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map modify(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.workflowService.modifyWorkflow(WorkflowForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 워크플로우 삭제 @RequestMapping(value = "/workflow/remove", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map removes(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.workflowService.removeWorkflows(WorkflowForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 워크플로우 엑셀 다운로드 @RequestMapping(value = "/workflow/downloadExcel", method = RequestMethod.POST) public ModelAndView downloadExcel(HttpServletRequest request, Model model) { return this.workflowService.downloadExcel(request, model); } // 워크플로우 담당부서 가져오기 @RequestMapping(value = "/workflow/findDepartments", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map findDepartments(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params)); this.departmentService.find(resJsonData, DepartmentCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable); return this.setSuccessMessage(resJsonData); } }