package kr.wisestone.owl.web.controller; import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.service.CustomFieldService; import kr.wisestone.owl.web.condition.CustomFieldCondition; import kr.wisestone.owl.web.form.CustomFieldForm; 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 javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; /** * Created by wisestone on 2018-05-29. */ @Controller public class CustomFieldController extends BaseController { @Autowired private CustomFieldService customFieldService; // 사용자 정의 필드 생성 @RequestMapping(value = "/customField/add", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map add(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.customFieldService.addCustomField(CustomFieldForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 사용자 정의 필드 조회 @RequestMapping(value = "/customField/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.customFieldService.findCustomField(resJsonData, CustomFieldCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable); return this.setSuccessMessage(resJsonData); } // 사용자 정의 필드 상세 조회 @RequestMapping(value = "/customField/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map detail(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.customFieldService.detailCustomField(resJsonData, CustomFieldCondition.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 사용자 정의 필드 수정 @RequestMapping(value = "/customField/modify", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map modify(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.customFieldService.modifyCustomField(CustomFieldForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 사용자 정의 필드 삭제 @SuppressWarnings("unchecked") @RequestMapping(value = "/customField/remove", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map removes(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.customFieldService.removeCustomFields(CustomFieldForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // 사용자 정의 필드 엑셀 다운로드 @RequestMapping(value = "/customField/downloadExcel", method = RequestMethod.POST) public ModelAndView downloadExcel(HttpServletRequest request, Model model) { return this.customFieldService.downloadExcel(request, model); } }