From 54b60cd564e25040b6996f7e0ada536ce0c7b194 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 29 May 2024 10:29:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20image=20controller=20=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/image/AiImageController.java | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java index 038b02454..f1decdc86 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java @@ -6,48 +6,33 @@ import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*; import cn.iocoder.yudao.module.ai.service.image.AiImageService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -// TODO @芋艿:整理接口定义 -// TODO @fan:参考 AiChatMessageController 改下 swagger 注解、注释 -/** - * ai作图 - * - * @author fansili - * @time 2024/4/25 15:49 - * @since 1.0 - */ -@Tag(name = "A10-ai作图") +@Tag(name = "管理后台 - Ai 绘画") @RestController @RequestMapping("/ai/image") @Slf4j -@AllArgsConstructor public class AiImageController { - // TODO @fan:使用 @Resource 注入哈;然后 aiImageService => imageService; - private final AiImageService aiImageService; + @Resource + private AiImageService aiImageService; - // TODO @fan:分页列表,建议是 getImagePage,包括接口 path 也建议改下哈; - // TODO @fan:@ModelAttribute 不需要哈; - // TODO @fan:这个要不搞成 my-page?因为是我的哈 - @Operation(summary = "获取image列表", description = "dall3、midjourney") - @GetMapping("/list") - public CommonResult> list(@Validated @ModelAttribute AiImageListReqVO req) { - // TODO @fan:import static,这样只要 success() 就行啦 - return CommonResult.success(aiImageService.list(req)); + @Operation(summary = "获取 - 我的分页列表", description = "dall3、midjourney") + @GetMapping("/my-page") + public CommonResult> myPage(@Validated AiImageListReqVO req) { + return success(aiImageService.list(req)); } - // TODO @fan:搞成 get-my? - // TODO @fan:方法名改下哈。 - @Operation(summary = "获取image信息", description = "获取image信息") - @GetMapping("/get") - public CommonResult get(@RequestParam("id") Long id) { - return CommonResult.success(aiImageService.get(id)); + @Operation(summary = "获取 - 我的 image 信息", description = "...") + @GetMapping("/get-my") + public CommonResult getMy(@RequestParam("id") Long id) { + return CommonResult.success(aiImageService.getMy(id)); } // TODO @fan:建议把 dallDrawing、midjourney 融合成一个 draw 接口,异步绘制;然后返回一个 id 给前端;前端通过 get 接口轮询,直到获取到生成成功 @@ -79,11 +64,11 @@ public class AiImageController { return success(null); } - // TODO @fan:delete-my?需要校验是不是当前人哈 @Operation(summary = "删除绘画记录", description = "") - @DeleteMapping("/delete") - public CommonResult delete(@RequestParam("id") Long id) { - aiImageService.delete(id); + @DeleteMapping("/delete-my") + public CommonResult deleteMy(@RequestParam("id") Long id) { + Long loginUserId = getLoginUserId(); + aiImageService.deleteMy(id, loginUserId); return success(null); }