Commit 54b60cd564e25040b6996f7e0ada536ce0c7b194
1 parent
1b725fd5
【解决todo】修改 image controller 命名
Showing
1 changed file
with
17 additions
and
32 deletions
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.*; | @@ -6,48 +6,33 @@ import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*; | ||
| 6 | import cn.iocoder.yudao.module.ai.service.image.AiImageService; | 6 | import cn.iocoder.yudao.module.ai.service.image.AiImageService; |
| 7 | import io.swagger.v3.oas.annotations.Operation; | 7 | import io.swagger.v3.oas.annotations.Operation; |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | 8 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | -import lombok.AllArgsConstructor; | 9 | +import jakarta.annotation.Resource; |
| 10 | import lombok.extern.slf4j.Slf4j; | 10 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 12 | import org.springframework.web.bind.annotation.*; | 12 | import org.springframework.web.bind.annotation.*; |
| 13 | 13 | ||
| 14 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 14 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 15 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 15 | 16 | ||
| 16 | -// TODO @芋艿:整理接口定义 | ||
| 17 | -// TODO @fan:参考 AiChatMessageController 改下 swagger 注解、注释 | ||
| 18 | -/** | ||
| 19 | - * ai作图 | ||
| 20 | - * | ||
| 21 | - * @author fansili | ||
| 22 | - * @time 2024/4/25 15:49 | ||
| 23 | - * @since 1.0 | ||
| 24 | - */ | ||
| 25 | -@Tag(name = "A10-ai作图") | 17 | +@Tag(name = "管理后台 - Ai 绘画") |
| 26 | @RestController | 18 | @RestController |
| 27 | @RequestMapping("/ai/image") | 19 | @RequestMapping("/ai/image") |
| 28 | @Slf4j | 20 | @Slf4j |
| 29 | -@AllArgsConstructor | ||
| 30 | public class AiImageController { | 21 | public class AiImageController { |
| 31 | 22 | ||
| 32 | - // TODO @fan:使用 @Resource 注入哈;然后 aiImageService => imageService; | ||
| 33 | - private final AiImageService aiImageService; | 23 | + @Resource |
| 24 | + private AiImageService aiImageService; | ||
| 34 | 25 | ||
| 35 | - // TODO @fan:分页列表,建议是 getImagePage,包括接口 path 也建议改下哈; | ||
| 36 | - // TODO @fan:@ModelAttribute 不需要哈; | ||
| 37 | - // TODO @fan:这个要不搞成 my-page?因为是我的哈 | ||
| 38 | - @Operation(summary = "获取image列表", description = "dall3、midjourney") | ||
| 39 | - @GetMapping("/list") | ||
| 40 | - public CommonResult<PageResult<AiImageListRespVO>> list(@Validated @ModelAttribute AiImageListReqVO req) { | ||
| 41 | - // TODO @fan:import static,这样只要 success() 就行啦 | ||
| 42 | - return CommonResult.success(aiImageService.list(req)); | 26 | + @Operation(summary = "获取 - 我的分页列表", description = "dall3、midjourney") |
| 27 | + @GetMapping("/my-page") | ||
| 28 | + public CommonResult<PageResult<AiImageListRespVO>> myPage(@Validated AiImageListReqVO req) { | ||
| 29 | + return success(aiImageService.list(req)); | ||
| 43 | } | 30 | } |
| 44 | 31 | ||
| 45 | - // TODO @fan:搞成 get-my? | ||
| 46 | - // TODO @fan:方法名改下哈。 | ||
| 47 | - @Operation(summary = "获取image信息", description = "获取image信息") | ||
| 48 | - @GetMapping("/get") | ||
| 49 | - public CommonResult<AiImageListRespVO> get(@RequestParam("id") Long id) { | ||
| 50 | - return CommonResult.success(aiImageService.get(id)); | 32 | + @Operation(summary = "获取 - 我的 image 信息", description = "...") |
| 33 | + @GetMapping("/get-my") | ||
| 34 | + public CommonResult<AiImageListRespVO> getMy(@RequestParam("id") Long id) { | ||
| 35 | + return CommonResult.success(aiImageService.getMy(id)); | ||
| 51 | } | 36 | } |
| 52 | 37 | ||
| 53 | // TODO @fan:建议把 dallDrawing、midjourney 融合成一个 draw 接口,异步绘制;然后返回一个 id 给前端;前端通过 get 接口轮询,直到获取到生成成功 | 38 | // TODO @fan:建议把 dallDrawing、midjourney 融合成一个 draw 接口,异步绘制;然后返回一个 id 给前端;前端通过 get 接口轮询,直到获取到生成成功 |
| @@ -79,11 +64,11 @@ public class AiImageController { | @@ -79,11 +64,11 @@ public class AiImageController { | ||
| 79 | return success(null); | 64 | return success(null); |
| 80 | } | 65 | } |
| 81 | 66 | ||
| 82 | - // TODO @fan:delete-my?需要校验是不是当前人哈 | ||
| 83 | @Operation(summary = "删除绘画记录", description = "") | 67 | @Operation(summary = "删除绘画记录", description = "") |
| 84 | - @DeleteMapping("/delete") | ||
| 85 | - public CommonResult<Void> delete(@RequestParam("id") Long id) { | ||
| 86 | - aiImageService.delete(id); | 68 | + @DeleteMapping("/delete-my") |
| 69 | + public CommonResult<Void> deleteMy(@RequestParam("id") Long id) { | ||
| 70 | + Long loginUserId = getLoginUserId(); | ||
| 71 | + aiImageService.deleteMy(id, loginUserId); | ||
| 87 | return success(null); | 72 | return success(null); |
| 88 | } | 73 | } |
| 89 | 74 |