【代码优化】AI:获取公开的分页

This commit is contained in:
YunaiV 2024-07-17 08:50:30 +08:00
parent ef4fb7ec05
commit cb59a61a04
5 changed files with 30 additions and 27 deletions

View File

@ -43,6 +43,13 @@ public class AiImageController {
return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
}
@GetMapping("/public-page")
@Operation(summary = "获取公开的绘图分页")
public CommonResult<PageResult<AiImageRespVO>> getImagePagePublic(AiImagePublicPageReqVO pageReqVO) {
PageResult<AiImageDO> pageResult = imageService.getImagePagePublic(pageReqVO);
return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
}
@GetMapping("/get-my")
@Operation(summary = "获取【我的】绘图记录")
@Parameter(name = "id", required = true, description = "绘画编号", example = "1024")
@ -128,10 +135,4 @@ public class AiImageController {
return success(true);
}
@GetMapping("/public-list")
@Operation(summary = "发布列表")
public CommonResult<PageResult<AiImageRespVO>> publicList(AiImagePublicListReqVO publicListReqVO) {
PageResult<AiImageDO> pageResult = imageService.publicList(publicListReqVO);
return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
}
}

View File

@ -4,9 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "Ai Image 发布列表 req")
@Schema(description = "管理后台 - AI 绘画公开的分页 Request VO")
@Data
public class AiImagePublicListReqVO extends PageParam {
public class AiImagePublicPageReqVO extends PageParam {
@Schema(description = "提示词")
private String prompt;

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicListReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePublicPageReqVO;
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
import org.apache.ibatis.annotations.Mapper;
@ -39,15 +39,16 @@ public interface AiImageMapper extends BaseMapperX<AiImageDO> {
.orderByDesc(AiImageDO::getId));
}
default PageResult<AiImageDO> selectPage(AiImagePublicPageReqVO pageReqVO) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<AiImageDO>()
.eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE)
.likeIfPresent(AiImageDO::getPrompt, pageReqVO.getPrompt())
.orderByDesc(AiImageDO::getId));
}
default List<AiImageDO> selectListByStatusAndPlatform(Integer status, String platform) {
return selectList(AiImageDO::getStatus, status,
AiImageDO::getPlatform, platform);
}
default PageResult<AiImageDO> selectPageOfPublicList(AiImagePublicListReqVO releaseListReqVO) {
return selectPage(releaseListReqVO, new LambdaQueryWrapperX<AiImageDO>()
.eqIfPresent(AiImageDO::getPublicStatus, Boolean.TRUE)
.eqIfPresent(AiImageDO::getPrompt, releaseListReqVO.getPrompt())
.orderByDesc(AiImageDO::getId));
}
}

View File

@ -27,6 +27,14 @@ public interface AiImageService {
*/
PageResult<AiImageDO> getImagePageMy(Long userId, PageParam pageReqVO);
/**
* 获取公开的绘图分页
*
* @param pageReqVO 分页条件
* @return 绘图分页
*/
PageResult<AiImageDO> getImagePagePublic(AiImagePublicPageReqVO pageReqVO);
/**
* 获得绘图记录
*
@ -116,11 +124,4 @@ public interface AiImageService {
*/
Long midjourneyAction(Long userId, AiMidjourneyActionReqVO reqVO);
/**
* 发布列表
* @param publicListReqVO
* @return
*/
PageResult<AiImageDO> publicList(AiImagePublicListReqVO publicListReqVO);
}

View File

@ -69,6 +69,11 @@ public class AiImageServiceImpl implements AiImageService {
return imageMapper.selectPage(userId, pageReqVO);
}
@Override
public PageResult<AiImageDO> getImagePagePublic(AiImagePublicPageReqVO pageReqVO) {
return imageMapper.selectPage(pageReqVO);
}
@Override
public AiImageDO getImage(Long id) {
return imageMapper.selectById(id);
@ -336,11 +341,6 @@ public class AiImageServiceImpl implements AiImageService {
return newImage.getId();
}
@Override
public PageResult<AiImageDO> publicList(AiImagePublicListReqVO publicListReqVO) {
return imageMapper.selectPageOfPublicList(publicListReqVO);
}
/**
* 获得自身的代理对象解决 AOP 生效问题
*