package com.jiayue.ipfcst.console.controller; import com.jiayue.ipfcst.common.core.exception.BusinessException; import com.jiayue.ipfcst.common.core.web.vo.ResponseVO; import com.jiayue.ipfcst.common.data.entity.OverhaulPlan; import com.jiayue.ipfcst.console.service.OverHaulPlanService; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 检修计划信息restful接口 * * @author tl * @version 3.0 * @since 2020/03/27 10:12 */ @RestController @RequestMapping("overHaulPlan") public class OverHaulOlanController { final private OverHaulPlanService overHaulPlanService; @Autowired public OverHaulOlanController(OverHaulPlanService overHaulPlanService) { this.overHaulPlanService = overHaulPlanService; } /** * 新增 检修计划接口 * * @param overhaulPlan * @return 操作结果 */ @PostMapping public ResponseVO insert(@RequestBody OverhaulPlan overhaulPlan) { this.overHaulPlanService.add(overhaulPlan); return ResponseVO.success(1); } /** * 修改 检修计划接口 */ @PutMapping public ResponseVO update(@RequestBody OverhaulPlan overhaulPlan) throws BusinessException { this.overHaulPlanService.save(overhaulPlan); return ResponseVO.success(1); } /** * 删除 检修计划接口 * * @param overhaulPlan * @return 操作结果 */ @DeleteMapping public ResponseVO delete(@RequestBody OverhaulPlan overhaulPlan) { this.overHaulPlanService.delete(overhaulPlan.getId()); return ResponseVO.success(1); } /** * 获取 检修计划接口 * * @param page 页码 * @param size 条数 * @return 操作结果 */ @SneakyThrows @GetMapping(value = "/{page}/{size}") public ResponseVO get(@PathVariable("page") Integer page, @PathVariable("size") Integer size) { OverhaulPlan overhaulPlan = new OverhaulPlan(); Page overhaulPlanCalendarPage = this.overHaulPlanService.get(overhaulPlan, page, size); return ResponseVO.success(overhaulPlanCalendarPage); } /** * 获取 检修计划接口 * * @param page 页码 * @param size 条数 * @return 操作结果 */ @SneakyThrows @GetMapping(value = "/{page}/{size}/{stationCode}") public ResponseVO getByStationCode(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) { OverhaulPlan overhaulPlan = new OverhaulPlan(); Page overhaulPlanCalendarPage = this.overHaulPlanService.getByStationCode(overhaulPlan, page, size, stationCode); return ResponseVO.success(overhaulPlanCalendarPage); } /** * 获取全部 检修计划接口 * * @return 操作结果 */ @SneakyThrows @GetMapping() public ResponseVO getAll() { List list = this.overHaulPlanService.getAll(); return ResponseVO.success(list); } }