package com.iailab.module.model.mcs.sche.controller;
|
|
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
|
import com.iailab.framework.common.pojo.CommonResult;
|
import com.iailab.framework.common.pojo.PageParam;
|
import com.iailab.framework.common.pojo.PageResult;
|
import com.iailab.framework.common.util.object.BeanUtils;
|
import com.iailab.framework.excel.core.util.ExcelUtils;
|
import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeRespVO;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeSaveReqVO;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
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 javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
import java.io.IOException;
|
import java.util.List;
|
|
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年09月06日
|
*/
|
@Tag(name = "模型服务 - 调度方案")
|
@RestController
|
@RequestMapping("/model/sche/scheme")
|
public class StScheduleSchemeController {
|
|
@Autowired
|
private StScheduleSchemeService stScheduleSchemeService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建调度方案")
|
@PreAuthorize("@ss.hasPermission('sche:scheme:create')")
|
public CommonResult<Boolean> create(@Valid @RequestBody StScheduleSchemeSaveReqVO createReqVO) {
|
stScheduleSchemeService.create(createReqVO);
|
return success(true);
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新调度方案")
|
@PreAuthorize("@ss.hasPermission('sche:scheme:update')")
|
public CommonResult<Boolean> update(@Valid @RequestBody StScheduleSchemeSaveReqVO updateReqVO) {
|
stScheduleSchemeService.update(updateReqVO);
|
return success(true);
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除调度方案")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('sche:scheme:delete')")
|
public CommonResult<Boolean> deleteTenant(@RequestParam("id") String id) {
|
stScheduleSchemeService.delete(id);
|
return success(true);
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得调度方案")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('sche:scheme:query')")
|
public CommonResult<StScheduleSchemeRespVO> getInfo(@RequestParam("id") String id) {
|
StScheduleSchemeEntity entity = stScheduleSchemeService.getInfo(id);
|
return success(BeanUtils.toBean(entity, StScheduleSchemeRespVO.class));
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得调度方案分页")
|
@PreAuthorize("@ss.hasPermission('sche:scheme:query')")
|
public CommonResult<PageResult<StScheduleSchemeRespVO>> getTenantPage(@Valid StScheduleSchemePageReqVO pageVO) {
|
PageResult<StScheduleSchemeEntity> pageResult = stScheduleSchemeService.page(pageVO);
|
return success(BeanUtils.toBean(pageResult, StScheduleSchemeRespVO.class));
|
}
|
|
@GetMapping("/export-excel")
|
@Operation(summary = "导出调度方案 Excel")
|
@PreAuthorize("@ss.hasPermission('system:tenant:export')")
|
@ApiAccessLog(operateType = EXPORT)
|
public void exportTenantExcel(@Valid StScheduleSchemePageReqVO exportReqVO,
|
HttpServletResponse response) throws IOException {
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
List<StScheduleSchemeEntity> list = stScheduleSchemeService.page(exportReqVO).getList();
|
// 导出 Excel
|
ExcelUtils.write(response, "调度方案.xls", "数据", StScheduleSchemeEntity.class,
|
BeanUtils.toBean(list, StScheduleSchemeEntity.class));
|
}
|
}
|