【增加】根据多个id获取 image 信息,用于前端轮训任务
This commit is contained in:
parent
39ecc7a037
commit
671c3016c8
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.ai.controller.admin.image;
|
package cn.iocoder.yudao.module.ai.controller.admin.image;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
|
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
@ -25,6 +26,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
@ -54,6 +59,19 @@ public class AiImageController {
|
||||||
return success(BeanUtils.toBean(image, AiImageRespVO.class));
|
return success(BeanUtils.toBean(image, AiImageRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取【我的】绘图记录 - ids")
|
||||||
|
@GetMapping("/get-my-ids")
|
||||||
|
public CommonResult<List<AiImageRespVO>> getImageMyIds(@RequestParam("ids") List<Long> ids) {
|
||||||
|
List<AiImageDO> imageList = imageService.getImageByIds(ids);
|
||||||
|
if (CollUtil.isEmpty(imageList)) {
|
||||||
|
return success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
List<AiImageDO> userImageList = imageList.stream()
|
||||||
|
.map(item -> ObjUtil.equal(getLoginUserId(), item.getUserId()) ? item : null)
|
||||||
|
.filter(Objects::nonNull).toList();
|
||||||
|
return success(BeanUtils.toBean(userImageList, AiImageRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "生成图片")
|
@Operation(summary = "生成图片")
|
||||||
@PostMapping("/draw")
|
@PostMapping("/draw")
|
||||||
public CommonResult<Long> drawImage(@Validated @RequestBody AiImageDrawReqVO drawReqVO) {
|
public CommonResult<Long> drawImage(@Validated @RequestBody AiImageDrawReqVO drawReqVO) {
|
||||||
|
|
|
@ -5,12 +5,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
|
||||||
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO;
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageRespVO;
|
||||||
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageUpdatePublicStatusReqVO;
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageUpdatePublicStatusReqVO;
|
||||||
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyActionReqVO;
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyActionReqVO;
|
||||||
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyImagineReqVO;
|
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.midjourney.AiMidjourneyImagineReqVO;
|
||||||
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
|
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AI 绘图 Service 接口
|
* AI 绘图 Service 接口
|
||||||
*
|
*
|
||||||
|
@ -35,6 +38,14 @@ public interface AiImageService {
|
||||||
*/
|
*/
|
||||||
AiImageDO getImage(Long id);
|
AiImageDO getImage(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得绘图记录 - 多个
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AiImageDO> getImageByIds(List<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绘制图片
|
* 绘制图片
|
||||||
*
|
*
|
||||||
|
|
|
@ -74,6 +74,11 @@ public class AiImageServiceImpl implements AiImageService {
|
||||||
return imageMapper.selectById(id);
|
return imageMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AiImageDO> getImageByIds(List<Long> ids) {
|
||||||
|
return imageMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long drawImage(Long userId, AiImageDrawReqVO drawReqVO) {
|
public Long drawImage(Long userId, AiImageDrawReqVO drawReqVO) {
|
||||||
// 1. 保存数据库
|
// 1. 保存数据库
|
||||||
|
|
Loading…
Reference in New Issue