Commit cb59a61a04698d498c9f9c86bf7a136f7fdff2f9
1 parent
ef4fb7ec
【代码优化】AI:获取公开的分页
Showing
5 changed files
with
30 additions
and
27 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/AiImageController.java
| @@ -43,6 +43,13 @@ public class AiImageController { | @@ -43,6 +43,13 @@ public class AiImageController { | ||
| 43 | return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); | 43 | return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | + @GetMapping("/public-page") | ||
| 47 | + @Operation(summary = "获取公开的绘图分页") | ||
| 48 | + public CommonResult<PageResult<AiImageRespVO>> getImagePagePublic(AiImagePublicPageReqVO pageReqVO) { | ||
| 49 | + PageResult<AiImageDO> pageResult = imageService.getImagePagePublic(pageReqVO); | ||
| 50 | + return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); | ||
| 51 | + } | ||
| 52 | + | ||
| 46 | @GetMapping("/get-my") | 53 | @GetMapping("/get-my") |
| 47 | @Operation(summary = "获取【我的】绘图记录") | 54 | @Operation(summary = "获取【我的】绘图记录") |
| 48 | @Parameter(name = "id", required = true, description = "绘画编号", example = "1024") | 55 | @Parameter(name = "id", required = true, description = "绘画编号", example = "1024") |
| @@ -128,10 +135,4 @@ public class AiImageController { | @@ -128,10 +135,4 @@ public class AiImageController { | ||
| 128 | return success(true); | 135 | return success(true); |
| 129 | } | 136 | } |
| 130 | 137 | ||
| 131 | - @GetMapping("/public-list") | ||
| 132 | - @Operation(summary = "发布列表") | ||
| 133 | - public CommonResult<PageResult<AiImageRespVO>> publicList(AiImagePublicListReqVO publicListReqVO) { | ||
| 134 | - PageResult<AiImageDO> pageResult = imageService.publicList(publicListReqVO); | ||
| 135 | - return success(BeanUtils.toBean(pageResult, AiImageRespVO.class)); | ||
| 136 | - } | ||
| 137 | } | 138 | } |
| 138 | \ No newline at end of file | 139 | \ No newline at end of file |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicListReqVO.java renamed to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePublicPageReqVO.java
| @@ -4,9 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | @@ -4,9 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| 7 | -@Schema(description = "Ai Image 发布列表 req") | 7 | +@Schema(description = "管理后台 - AI 绘画公开的分页 Request VO") |
| 8 | @Data | 8 | @Data |
| 9 | -public class AiImagePublicListReqVO extends PageParam { | 9 | +public class AiImagePublicPageReqVO extends PageParam { |
| 10 | 10 | ||
| 11 | @Schema(description = "提示词") | 11 | @Schema(description = "提示词") |
| 12 | private String prompt; | 12 | private String prompt; |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; | 7 | import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO; |
| 8 | -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicListReqVO; | 8 | +import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicPageReqVO; |
| 9 | import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; | 9 | import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; |
| 10 | import org.apache.ibatis.annotations.Mapper; | 10 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 11 | ||
| @@ -39,15 +39,16 @@ public interface AiImageMapper extends BaseMapperX<AiImageDO> { | @@ -39,15 +39,16 @@ public interface AiImageMapper extends BaseMapperX<AiImageDO> { | ||
| 39 | .orderByDesc(AiImageDO::getId)); | 39 | .orderByDesc(AiImageDO::getId)); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | + default PageResult<AiImageDO> selectPage(AiImagePublicPageReqVO pageReqVO) { | ||
| 43 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<AiImageDO>() | ||
| 44 | + .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) | ||
| 45 | + .likeIfPresent(AiImageDO::getPrompt, pageReqVO.getPrompt()) | ||
| 46 | + .orderByDesc(AiImageDO::getId)); | ||
| 47 | + } | ||
| 48 | + | ||
| 42 | default List<AiImageDO> selectListByStatusAndPlatform(Integer status, String platform) { | 49 | default List<AiImageDO> selectListByStatusAndPlatform(Integer status, String platform) { |
| 43 | return selectList(AiImageDO::getStatus, status, | 50 | return selectList(AiImageDO::getStatus, status, |
| 44 | AiImageDO::getPlatform, platform); | 51 | AiImageDO::getPlatform, platform); |
| 45 | } | 52 | } |
| 46 | 53 | ||
| 47 | - default PageResult<AiImageDO> selectPageOfPublicList(AiImagePublicListReqVO releaseListReqVO) { | ||
| 48 | - return selectPage(releaseListReqVO, new LambdaQueryWrapperX<AiImageDO>() | ||
| 49 | - .eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE) | ||
| 50 | - .eqIfPresent(AiImageDO::getPrompt, releaseListReqVO.getPrompt()) | ||
| 51 | - .orderByDesc(AiImageDO::getId)); | ||
| 52 | - } | ||
| 53 | } | 54 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java
| @@ -28,6 +28,14 @@ public interface AiImageService { | @@ -28,6 +28,14 @@ public interface AiImageService { | ||
| 28 | PageResult<AiImageDO> getImagePageMy(Long userId, PageParam pageReqVO); | 28 | PageResult<AiImageDO> getImagePageMy(Long userId, PageParam pageReqVO); |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | + * 获取公开的绘图分页 | ||
| 32 | + * | ||
| 33 | + * @param pageReqVO 分页条件 | ||
| 34 | + * @return 绘图分页 | ||
| 35 | + */ | ||
| 36 | + PageResult<AiImageDO> getImagePagePublic(AiImagePublicPageReqVO pageReqVO); | ||
| 37 | + | ||
| 38 | + /** | ||
| 31 | * 获得绘图记录 | 39 | * 获得绘图记录 |
| 32 | * | 40 | * |
| 33 | * @param id 绘图编号 | 41 | * @param id 绘图编号 |
| @@ -116,11 +124,4 @@ public interface AiImageService { | @@ -116,11 +124,4 @@ public interface AiImageService { | ||
| 116 | */ | 124 | */ |
| 117 | Long midjourneyAction(Long userId, AiMidjourneyActionReqVO reqVO); | 125 | Long midjourneyAction(Long userId, AiMidjourneyActionReqVO reqVO); |
| 118 | 126 | ||
| 119 | - /** | ||
| 120 | - * 发布列表 | ||
| 121 | - * @param publicListReqVO | ||
| 122 | - * @return | ||
| 123 | - */ | ||
| 124 | - PageResult<AiImageDO> publicList(AiImagePublicListReqVO publicListReqVO); | ||
| 125 | - | ||
| 126 | } | 127 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java
| @@ -70,6 +70,11 @@ public class AiImageServiceImpl implements AiImageService { | @@ -70,6 +70,11 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | @Override | 72 | @Override |
| 73 | + public PageResult<AiImageDO> getImagePagePublic(AiImagePublicPageReqVO pageReqVO) { | ||
| 74 | + return imageMapper.selectPage(pageReqVO); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 73 | public AiImageDO getImage(Long id) { | 78 | public AiImageDO getImage(Long id) { |
| 74 | return imageMapper.selectById(id); | 79 | return imageMapper.selectById(id); |
| 75 | } | 80 | } |
| @@ -336,11 +341,6 @@ public class AiImageServiceImpl implements AiImageService { | @@ -336,11 +341,6 @@ public class AiImageServiceImpl implements AiImageService { | ||
| 336 | return newImage.getId(); | 341 | return newImage.getId(); |
| 337 | } | 342 | } |
| 338 | 343 | ||
| 339 | - @Override | ||
| 340 | - public PageResult<AiImageDO> publicList(AiImagePublicListReqVO publicListReqVO) { | ||
| 341 | - return imageMapper.selectPageOfPublicList(publicListReqVO); | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | /** | 344 | /** |
| 345 | * 获得自身的代理对象,解决 AOP 生效问题 | 345 | * 获得自身的代理对象,解决 AOP 生效问题 |
| 346 | * | 346 | * |