package kr.wisestone.owl.web.controller; import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.service.EventService; import kr.wisestone.owl.web.condition.EventCondition; import kr.wisestone.owl.web.form.EventForm; 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.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 java.util.HashMap; import java.util.Map; /** * Create By J E O N G - S U N / 2019-05-24 */ @Controller public class EventController extends BaseController { @Autowired private EventService eventService; // event 생성 @RequestMapping(value = "/event/add", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map add(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.eventService.addEvent(EventForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // event 조회 @RequestMapping(value = "/event/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.eventService.findEvent(resJsonData, EventCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable); return this.setSuccessMessage(resJsonData); } // event 상세 조회 @RequestMapping(value = "/event/detail", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map detail(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.eventService.detailEvent(resJsonData, EventCondition.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // event 수정 @RequestMapping(value = "/event/modify", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map modify(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.eventService.modifyEvent(EventForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } // event 할성 @RequestMapping(value = "/event/activation", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Map activation(@RequestBody Map> params) { Map resJsonData = new HashMap<>(); this.eventService.activeEvent(EventForm.make(params.get(Constants.REQ_KEY_CONTENT))); return this.setSuccessMessage(resJsonData); } }