|
@@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.ai.controller.admin.image;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.*;
|
|
|
+import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
|
|
|
import cn.iocoder.yudao.module.ai.service.image.AiImageService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
@@ -24,25 +26,33 @@ public class AiImageController {
|
|
|
@Resource
|
|
|
private AiImageService aiImageService;
|
|
|
|
|
|
- // TODO @fan:方法名叫做,getImagePageMy ;我们的命名,还是以动名词哈。不考虑省略名词的原因,是担心一个 Service 扩多个模块,纯粹动词无法表达
|
|
|
@Operation(summary = "获取【我的】绘图分页")
|
|
|
@GetMapping("/my-page")
|
|
|
- public CommonResult<PageResult<AiImageListRespVO>> myPage(@Validated AiImageListReqVO req) {
|
|
|
- return success(aiImageService.list(req));
|
|
|
+ public CommonResult<PageResult<AiImagePageMyRespVO>> getImagePageMy(@Validated AiImageListReqVO req) {
|
|
|
+ // 转换 resp
|
|
|
+ PageResult<AiImageDO> pageResult = aiImageService.getImagePageMy(getLoginUserId(), req);
|
|
|
+ // 转换 PageResult<AiImageListRespVO> 返回
|
|
|
+ PageResult<AiImagePageMyRespVO> result = new PageResult<>();
|
|
|
+ result.setTotal(pageResult.getTotal());
|
|
|
+ result.setList(BeanUtils.toBean(pageResult.getList(), AiImagePageMyRespVO.class));
|
|
|
+ return success(result);
|
|
|
}
|
|
|
|
|
|
// TODO @fan:类似 /my-page 的建议
|
|
|
@Operation(summary = "获取【我的】绘图记录", description = "...")
|
|
|
@GetMapping("/get-my")
|
|
|
- public CommonResult<AiImageListRespVO> getMy(@RequestParam("id") Long id) {
|
|
|
- return CommonResult.success(aiImageService.getMy(id));
|
|
|
+ public CommonResult<AiImagePageMyRespVO> getMy(@RequestParam("id") Long id) {
|
|
|
+ // 获取 image 信息
|
|
|
+ AiImageDO imageDO = aiImageService.getMy(id);
|
|
|
+ // 转 resp 并返回
|
|
|
+ return CommonResult.success(BeanUtils.toBean(imageDO, AiImagePageMyRespVO.class));
|
|
|
}
|
|
|
|
|
|
// TODO @fan:建议把 dallDrawing、midjourney 融合成一个 draw 接口,异步绘制;然后返回一个 id 给前端;前端通过 get 接口轮询,直到获取到生成成功
|
|
|
@Operation(summary = "dall2/dall3绘画", description = "openAi dall3是付费的!")
|
|
|
@PostMapping("/dall")
|
|
|
- public AiImageDallRespVO dall(@Validated @RequestBody AiImageDallReqVO req) {
|
|
|
- return aiImageService.dall(req);
|
|
|
+ public CommonResult<Long> dall(@Validated @RequestBody AiImageDallReqVO req) {
|
|
|
+ return success(aiImageService.dall(getLoginUserId(), req));
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "midjourney绘画", description = "midjourney图片绘画流程:1、提交任务 2、获取完成的任务 3、选择对应功能 4、获取最终结果")
|
|
@@ -73,9 +83,7 @@ public class AiImageController {
|
|
|
@DeleteMapping("/delete-my")
|
|
|
@Parameter(name = "id", required = true, description = "绘画编号", example = "1024")
|
|
|
public CommonResult<Void> deleteMy(@RequestParam("id") Long id) {
|
|
|
- // TODO @fan:这种一次性的 loginUserId,可以不用定义变量,直接当参数传递
|
|
|
- Long loginUserId = getLoginUserId();
|
|
|
- aiImageService.deleteMy(id, loginUserId);
|
|
|
+ aiImageService.deleteMy(id, getLoginUserId());
|
|
|
return success(null);
|
|
|
}
|
|
|
|