package com.iailab.module.model.mcs.sche.controller;
|
|
import com.iailab.framework.common.exception.ErrorCode;
|
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.StScheduleEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleService;
|
import com.iailab.module.model.mcs.sche.vo.StSchedulePageReqVO;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleRespVO;
|
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月20日 13:51
|
*/
|
@RestController
|
@RequestMapping("/sche/schedule")
|
public class StScheduleController {
|
@Autowired
|
private StScheduleService stScheduleService;
|
|
/**
|
* 调度列表
|
*/
|
@GetMapping("/page")
|
public CommonResult<PageResult<StScheduleRespVO>> page(@Validated StSchedulePageReqVO reqVO) {
|
PageResult<StScheduleEntity> page = stScheduleService.page(reqVO);
|
|
return success(BeanUtils.toBean(page, StScheduleRespVO.class));
|
}
|
|
/**
|
* 调度信息
|
*/
|
@GetMapping("/info/{id}")
|
public CommonResult<StScheduleEntity> info(@PathVariable("id") String id){
|
StScheduleEntity schedule = stScheduleService.selectById(id);
|
return success(schedule);
|
}
|
|
/**
|
* 保存调度
|
*/
|
@PostMapping("/create")
|
public CommonResult<Boolean> save(@RequestBody StScheduleEntity schedule){
|
int count = stScheduleService.check(schedule);
|
if (count > 0) {
|
ErrorCode errorCode = new ErrorCode(999, "名称重复");
|
return error(errorCode);
|
}
|
stScheduleService.saveSchedule(schedule);
|
return success(true);
|
}
|
|
/**
|
* 修改调度
|
*/
|
@PutMapping("/update")
|
public CommonResult<Boolean> update(@RequestBody StScheduleEntity schedule){
|
stScheduleService.update(schedule);
|
return success(true);
|
}
|
|
/**
|
* 删除调度
|
*/
|
@DeleteMapping("/delete")
|
public CommonResult<Boolean> delete(@RequestParam("id") String id){
|
stScheduleService.deleteBatch(new String[]{id});
|
return success(true);
|
}
|
}
|