mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
【增加】根据多个id获取 image 信息,用于前端轮训任务
This commit is contained in:
parent
39ecc7a037
commit
671c3016c8
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.ai.controller.admin.image;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
|
||||
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.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.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@ -54,6 +59,19 @@ public class AiImageController {
|
||||
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 = "生成图片")
|
||||
@PostMapping("/draw")
|
||||
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.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.AiImageRespVO;
|
||||
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.AiMidjourneyImagineReqVO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI 绘图 Service 接口
|
||||
*
|
||||
@ -35,6 +38,14 @@ public interface AiImageService {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AiImageDO> getImageByIds(List<Long> ids) {
|
||||
return imageMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long drawImage(Long userId, AiImageDrawReqVO drawReqVO) {
|
||||
// 1. 保存数据库
|
||||
|
Loading…
Reference in New Issue
Block a user