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.framework.common.util.object.ConvertUtils; import com.iailab.module.model.mcs.sche.dto.StScheduleModelDto; import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; import com.iailab.module.model.mcs.sche.service.StScheduleModelService; import com.iailab.module.model.mcs.sche.vo.StScheduleModelRespVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Map; import static com.iailab.framework.common.pojo.CommonResult.error; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @date 2021年07月20日 14:35 */ @RestController @RequestMapping("/sche/schedule-model") public class StScheduleModelController { @Autowired private StScheduleModelService stScheduleModelService; /** * 调度模型类型列表 */ @GetMapping("/page") public CommonResult> page(@RequestParam Map params) { PageResult page = stScheduleModelService.getPageList(params); return success(BeanUtils.toBean(page, StScheduleModelRespVO.class)); } /** * 调度模型类型信息 */ @GetMapping("/get") public CommonResult info(@RequestParam("id") String id){ StScheduleModelDto scheduleMode = stScheduleModelService.getDetailById(id); return success(scheduleMode); } /** * 保存调度模型类型 */ @PostMapping("/create") public CommonResult save(@RequestBody StScheduleModelDto scheduleMode){ StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class); int count = stScheduleModelService.check(stScheduleModelEntity); if (count > 0) { return error(999, "名称或编号重复"); } stScheduleModelService.saveStScheduleModel(scheduleMode); return success(true); } /** * 修改调度模型类型 */ @PutMapping("/update") public CommonResult update(@RequestBody StScheduleModelDto scheduleMode){ StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class); int count = stScheduleModelService.check(stScheduleModelEntity); if (count > 0) { return error(999, "名称或编号重复"); } stScheduleModelService.update(scheduleMode); return success(true); } /** * 删除调度模型类型 */ @DeleteMapping("/delete") public CommonResult delete(@RequestParam("id") String id){ stScheduleModelService.deleteBatch(new String[]{id}); return success(true); } }