| | |
| | | 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.StScheduleModelPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleModelRespVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleModelSaveReqVO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import javax.validation.Valid; |
| | | |
| | | 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 |
| | | */ |
| | | @Tag(name = "模型服务 - 调度模型管理") |
| | | @RestController |
| | | @RequestMapping("/sche/schedule-model") |
| | | @RequestMapping("/model/sche/model") |
| | | public class StScheduleModelController { |
| | | |
| | | @Autowired |
| | | private StScheduleModelService stScheduleModelService; |
| | | |
| | | /** |
| | | * 调度模型类型列表 |
| | | */ |
| | | @GetMapping("/page") |
| | | public CommonResult<PageResult<StScheduleModelRespVO>> page(@RequestParam Map<String, Object> params) { |
| | | PageResult<StScheduleModelRespVO> page = stScheduleModelService.getPageList(params); |
| | | |
| | | @Operation(summary = "获得分页") |
| | | @PreAuthorize("@ss.hasPermission('sche:model:query')") |
| | | public CommonResult<PageResult<StScheduleModelRespVO>> page(@Valid StScheduleModelPageReqVO reqVO) { |
| | | PageResult<StScheduleModelEntity> page = stScheduleModelService.page(reqVO); |
| | | return success(BeanUtils.toBean(page, StScheduleModelRespVO.class)); |
| | | } |
| | | |
| | | /** |
| | | * 调度模型类型信息 |
| | | */ |
| | | @GetMapping("/get") |
| | | public CommonResult<StScheduleModelDto> info(@RequestParam("id") String id){ |
| | | StScheduleModelDto scheduleMode = stScheduleModelService.getDetailById(id); |
| | | return success(scheduleMode); |
| | | @Operation(summary = "获得详情") |
| | | @PreAuthorize("@ss.hasPermission('sche:model:query')") |
| | | public CommonResult<StScheduleModelRespVO> get(@RequestParam("id") String id){ |
| | | StScheduleModelEntity data = stScheduleModelService.get(id); |
| | | return success(BeanUtils.toBean(data, StScheduleModelRespVO.class)); |
| | | } |
| | | |
| | | /** |
| | | * 保存调度模型类型 |
| | | */ |
| | | @PostMapping("/create") |
| | | public CommonResult<Boolean> save(@RequestBody StScheduleModelDto scheduleMode){ |
| | | StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class); |
| | | int count = stScheduleModelService.check(stScheduleModelEntity); |
| | | @Operation(summary = "创建模型") |
| | | @PreAuthorize("@ss.hasPermission('sche:model:create')") |
| | | public CommonResult<Boolean> save(@Valid @RequestBody StScheduleModelSaveReqVO reqVO){ |
| | | Long count = stScheduleModelService.check(reqVO); |
| | | if (count > 0) { |
| | | return error(999, "名称或编号重复"); |
| | | } |
| | | stScheduleModelService.saveStScheduleModel(scheduleMode); |
| | | stScheduleModelService.create(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | /** |
| | | * 修改调度模型类型 |
| | | */ |
| | | @PutMapping("/update") |
| | | public CommonResult<Boolean> update(@RequestBody StScheduleModelDto scheduleMode){ |
| | | StScheduleModelEntity stScheduleModelEntity = ConvertUtils.sourceToTarget(scheduleMode, StScheduleModelEntity.class); |
| | | int count = stScheduleModelService.check(stScheduleModelEntity); |
| | | @Operation(summary = "更新模型") |
| | | @PreAuthorize("@ss.hasPermission('sche:model:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody StScheduleModelSaveReqVO reqVO){ |
| | | Long count = stScheduleModelService.check(reqVO); |
| | | if (count > 0) { |
| | | return error(999, "名称或编号重复"); |
| | | } |
| | | stScheduleModelService.update(scheduleMode); |
| | | stScheduleModelService.update(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | /** |
| | | * 删除调度模型类型 |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除模型") |
| | | @PreAuthorize("@ss.hasPermission('sche:model:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") String id){ |
| | | stScheduleModelService.deleteBatch(new String[]{id}); |
| | | stScheduleModelService.delete(id); |
| | | return success(true); |
| | | } |
| | | } |