package com.iailab.module.model.mcs.sche.controller; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.model.mcs.sche.entity.StScheduleObjectEntity; import com.iailab.module.model.mcs.sche.service.StScheduleObjectService; import com.iailab.module.model.mcs.sche.vo.StScheduleObjectPageReqVO; import com.iailab.module.model.mcs.sche.vo.StScheduleObjectRespVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import static com.iailab.framework.common.pojo.CommonResult.error; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @date 2021年07月21日 8:50 */ @RestController @RequestMapping("/sche/schedule-object") public class StScheduleObjectController { @Autowired private StScheduleObjectService stScheduleObjectService; /** * 调度对象类型列表 */ @GetMapping("/page") public CommonResult> page(@Validated StScheduleObjectPageReqVO reqVO) { PageResult page = stScheduleObjectService.page(reqVO); return success(BeanUtils.toBean(page, StScheduleObjectRespVO.class)); } /** * 调度对象类型信息 */ @GetMapping("/info/{id}") public CommonResult info(@PathVariable("id") String id) { StScheduleObjectEntity scheduleObject = stScheduleObjectService.selectById(id); return success(scheduleObject); } /** * 保存调度对象类型 */ @PostMapping("/create") public CommonResult save(@RequestBody StScheduleObjectEntity scheduleObject) { int count = stScheduleObjectService.check(scheduleObject); if (count > 0) { return error(999, "名称或编号重复"); } stScheduleObjectService.saveStScheduleObject(scheduleObject); return success(true); } /** * 修改调度对象类型 */ @PutMapping("/update") public CommonResult update(@RequestBody StScheduleObjectEntity scheduleObject) { int count = stScheduleObjectService.check(scheduleObject); if (count > 0) { return error(999, "名称或编号重复"); } stScheduleObjectService.update(scheduleObject); return success(true); } /** * 删除调度对象类型 */ @DeleteMapping("/delete") public CommonResult delete(@RequestParam("id") String id) { stScheduleObjectService.deleteBatch(new String[]{id}); return success(true); } }