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.StScheduleEnergyTypeEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleEnergyTypeService;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleEnergyTypePageReqVO;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleEnergyTypeRespVO;
|
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 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:02
|
*/
|
@RestController
|
@RequestMapping("/sche/schedule-energy-type")
|
public class StScheduleEnergyTypeController {
|
@Autowired
|
private StScheduleEnergyTypeService stScheduleEnergyTypeService;
|
|
/**
|
* 调度类型列表
|
*/
|
@GetMapping("/page")
|
public CommonResult<PageResult<StScheduleEnergyTypeRespVO>> page(@Validated StScheduleEnergyTypePageReqVO reqVO) {
|
PageResult<StScheduleEnergyTypeEntity> page = stScheduleEnergyTypeService.page(reqVO);
|
|
return success(BeanUtils.toBean(page, StScheduleEnergyTypeRespVO.class));
|
}
|
|
/**
|
* 调度能源类型信息
|
*/
|
@GetMapping("/info/{id}")
|
public CommonResult<StScheduleEnergyTypeEntity> info(@PathVariable("id") String id){
|
StScheduleEnergyTypeEntity scheduleEnergyType = stScheduleEnergyTypeService.selectById(id);
|
return success(scheduleEnergyType);
|
}
|
|
/**
|
* 保存调度能源类型
|
*/
|
@PostMapping
|
public CommonResult<Boolean> save(@RequestBody StScheduleEnergyTypeEntity scheduleEnergyType){
|
int count = stScheduleEnergyTypeService.check(scheduleEnergyType);
|
if (count > 0) {
|
ErrorCode errorCode = new ErrorCode(999, "名称重复");
|
return error(errorCode);
|
}
|
stScheduleEnergyTypeService.saveScheduleEnergyType(scheduleEnergyType);
|
return success(true);
|
}
|
|
/**
|
* 修改调度能源类型
|
*/
|
@PutMapping
|
public CommonResult<Boolean> update(@RequestBody StScheduleEnergyTypeEntity scheduleEnergyType){
|
int count = stScheduleEnergyTypeService.check(scheduleEnergyType);
|
if (count > 0) {
|
ErrorCode errorCode = new ErrorCode(999, "名称重复");
|
return error(errorCode);
|
}
|
stScheduleEnergyTypeService.update(scheduleEnergyType);
|
return success(true);
|
}
|
|
/**
|
* 删除调度能源类型
|
*/
|
@DeleteMapping("/delete")
|
public CommonResult<Boolean> delete(@RequestParam("id") String id){
|
stScheduleEnergyTypeService.deleteBatch(new String[]{id});
|
return success(true);
|
}
|
}
|