潘志宝
2024-12-25 874dd8d939b4ae61efbb799855c9ddf328722972
提交 | 用户 | 时间
9cfbab 1 package com.iailab.module.model.mcs.sche.controller.admin;
bbc1ee 2
3 import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.pojo.PageParam;
6 import com.iailab.framework.common.pojo.PageResult;
7 import com.iailab.framework.common.util.object.BeanUtils;
8 import com.iailab.framework.excel.core.util.ExcelUtils;
9 import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity;
10 import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService;
11 import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO;
12 import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeRespVO;
13 import com.iailab.module.model.mcs.sche.vo.StScheduleSchemeSaveReqVO;
14 import io.swagger.v3.oas.annotations.Operation;
15 import io.swagger.v3.oas.annotations.Parameter;
16 import io.swagger.v3.oas.annotations.tags.Tag;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.security.access.prepost.PreAuthorize;
19 import org.springframework.web.bind.annotation.*;
20
21 import javax.servlet.http.HttpServletResponse;
22 import javax.validation.Valid;
23 import java.io.IOException;
24 import java.util.List;
25
26 import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
27 import static com.iailab.framework.common.pojo.CommonResult.success;
28
29 /**
30  * @author PanZhibao
31  * @Description
32  * @createTime 2024年09月06日
33  */
34 @Tag(name = "模型服务 - 调度方案")
35 @RestController
36 @RequestMapping("/model/sche/scheme")
37 public class StScheduleSchemeController {
38
39     @Autowired
40     private StScheduleSchemeService stScheduleSchemeService;
41
42     @PostMapping("/create")
43     @Operation(summary = "创建调度方案")
44     @PreAuthorize("@ss.hasPermission('sche:scheme:create')")
45     public CommonResult<Boolean> create(@Valid @RequestBody StScheduleSchemeSaveReqVO createReqVO) {
46         stScheduleSchemeService.create(createReqVO);
47         return success(true);
48     }
49
50     @PutMapping("/update")
51     @Operation(summary = "更新调度方案")
52     @PreAuthorize("@ss.hasPermission('sche:scheme:update')")
53     public CommonResult<Boolean> update(@Valid @RequestBody StScheduleSchemeSaveReqVO updateReqVO) {
54         stScheduleSchemeService.update(updateReqVO);
55         return success(true);
56     }
57
58     @DeleteMapping("/delete")
59     @Operation(summary = "删除调度方案")
60     @Parameter(name = "id", description = "编号", required = true, example = "1024")
61     @PreAuthorize("@ss.hasPermission('sche:scheme:delete')")
62     public CommonResult<Boolean> deleteTenant(@RequestParam("id") String id) {
63         stScheduleSchemeService.delete(id);
64         return success(true);
65     }
66
67     @GetMapping("/get")
68     @Operation(summary = "获得调度方案")
69     @Parameter(name = "id", description = "编号", required = true, example = "1024")
70     @PreAuthorize("@ss.hasPermission('sche:scheme:query')")
71     public CommonResult<StScheduleSchemeRespVO> getInfo(@RequestParam("id") String id) {
72         StScheduleSchemeEntity entity = stScheduleSchemeService.getInfo(id);
73         return success(BeanUtils.toBean(entity, StScheduleSchemeRespVO.class));
74     }
75
76     @GetMapping("/page")
77     @Operation(summary = "获得调度方案分页")
78     @PreAuthorize("@ss.hasPermission('sche:scheme:query')")
898006 79     public CommonResult<PageResult<StScheduleSchemeRespVO>> getPage(@Valid StScheduleSchemePageReqVO pageVO) {
bbc1ee 80         PageResult<StScheduleSchemeEntity> pageResult = stScheduleSchemeService.page(pageVO);
81         return success(BeanUtils.toBean(pageResult, StScheduleSchemeRespVO.class));
82     }
83
84     @GetMapping("/export-excel")
85     @Operation(summary = "导出调度方案 Excel")
86     @PreAuthorize("@ss.hasPermission('system:tenant:export')")
87     @ApiAccessLog(operateType = EXPORT)
88     public void exportTenantExcel(@Valid StScheduleSchemePageReqVO exportReqVO,
89                                   HttpServletResponse response) throws IOException {
90         exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
91         List<StScheduleSchemeEntity> list = stScheduleSchemeService.page(exportReqVO).getList();
92         // 导出 Excel
93         ExcelUtils.write(response, "调度方案.xls", "数据", StScheduleSchemeEntity.class,
94                 BeanUtils.toBean(list, StScheduleSchemeEntity.class));
95     }
96 }