|
@@ -0,0 +1,93 @@
|
|
|
|
+package cn.iocoder.yudao.module.infra.controller.admin.aipromptmanagement;
|
|
|
|
+
|
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
+import cn.iocoder.yudao.module.infra.controller.admin.aipromptmanagement.vo.AiPromptManagementPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.infra.controller.admin.aipromptmanagement.vo.AiPromptManagementRespVO;
|
|
|
|
+import cn.iocoder.yudao.module.infra.controller.admin.aipromptmanagement.vo.AiPromptManagementSaveReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.infra.dal.dataobject.aipromptmanagement.AiPromptManagementDO;
|
|
|
|
+import cn.iocoder.yudao.module.infra.service.aipromptmanagement.AiPromptManagementService;
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import jakarta.annotation.Resource;
|
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
+import jakarta.validation.Valid;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
+
|
|
|
|
+@Tag(name = "管理后台 - AI 提示词管理")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/infra/ai-prompt-management")
|
|
|
|
+@Validated
|
|
|
|
+public class AiPromptManagementController {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private AiPromptManagementService aiPromptManagementService;
|
|
|
|
+
|
|
|
|
+ @PostMapping("/create")
|
|
|
|
+ @Operation(summary = "创建AI 提示词管理")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:create')")
|
|
|
|
+ public CommonResult<Long> createAiPromptManagement(@Valid @RequestBody AiPromptManagementSaveReqVO createReqVO) {
|
|
|
|
+ return success(aiPromptManagementService.createAiPromptManagement(createReqVO));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PutMapping("/update")
|
|
|
|
+ @Operation(summary = "更新AI 提示词管理")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:update')")
|
|
|
|
+ public CommonResult<Boolean> updateAiPromptManagement(@Valid @RequestBody AiPromptManagementSaveReqVO updateReqVO) {
|
|
|
|
+ aiPromptManagementService.updateAiPromptManagement(updateReqVO);
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
|
+ @Operation(summary = "删除AI 提示词管理")
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:delete')")
|
|
|
|
+ public CommonResult<Boolean> deleteAiPromptManagement(@RequestParam("id") Long id) {
|
|
|
|
+ aiPromptManagementService.deleteAiPromptManagement(id);
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
+ @Operation(summary = "获得AI 提示词管理")
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:query')")
|
|
|
|
+ public CommonResult<AiPromptManagementRespVO> getAiPromptManagement(@RequestParam("id") Long id) {
|
|
|
|
+ AiPromptManagementDO aiPromptManagement = aiPromptManagementService.getAiPromptManagement(id);
|
|
|
|
+ return success(BeanUtils.toBean(aiPromptManagement, AiPromptManagementRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ @Operation(summary = "获得AI 提示词管理分页")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:query')")
|
|
|
|
+ public CommonResult<PageResult<AiPromptManagementRespVO>> getAiPromptManagementPage(@Valid AiPromptManagementPageReqVO pageReqVO) {
|
|
|
|
+ PageResult<AiPromptManagementDO> pageResult = aiPromptManagementService.getAiPromptManagementPage(pageReqVO);
|
|
|
|
+ return success(BeanUtils.toBean(pageResult, AiPromptManagementRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/export-excel")
|
|
|
|
+ @Operation(summary = "导出AI 提示词管理 Excel")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:ai-prompt-management:export')")
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
+ public void exportAiPromptManagementExcel(@Valid AiPromptManagementPageReqVO pageReqVO,
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
+ List<AiPromptManagementDO> list = aiPromptManagementService.getAiPromptManagementPage(pageReqVO).getList();
|
|
|
|
+ // 导出 Excel
|
|
|
|
+ ExcelUtils.write(response, "AI 提示词管理.xls", "数据", AiPromptManagementRespVO.class,
|
|
|
|
+ BeanUtils.toBean(list, AiPromptManagementRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|