From 1c0cf4b860596de08a88602b2e3b8725b6f46502 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 30 May 2024 10:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=BD=AC=E6=8D=A2=E9=83=BD=E4=B8=8D=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=20convert=20=E9=87=87=E7=94=A8=20BeanUtils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stRespVO.java => AiImagePageMyRespVO.java} | 7 +- .../module/ai/convert/AiImageConvert.java | 74 ------------------- .../YuDaoMidjourneyMessageHandler.java | 33 ++++----- 3 files changed, 16 insertions(+), 98 deletions(-) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/{AiImageListRespVO.java => AiImagePageMyRespVO.java} (87%) delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiImageConvert.java diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageListRespVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePageMyRespVO.java similarity index 87% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageListRespVO.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePageMyRespVO.java index 1ee14cb89..e542879ca 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImageListRespVO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/image/vo/AiImagePageMyRespVO.java @@ -1,15 +1,10 @@ package cn.iocoder.yudao.module.ai.controller.admin.image.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.experimental.Accessors; -import java.time.LocalDateTime; import java.util.Map; // TODO @fan:可以考虑,复用 AiImageDallRespVO,统一成 AIImageRespVO @@ -22,7 +17,7 @@ import java.util.Map; */ @Data @Accessors(chain = true) -public class AiImageListRespVO extends PageParam { +public class AiImagePageMyRespVO extends PageParam { @Schema(description = "id编号", example = "1") private Long id; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiImageConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiImageConvert.java deleted file mode 100644 index d094f489d..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiImageConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.ai.convert; - -import org.springframework.ai.models.midjourney.MidjourneyMessage; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDallRespVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageListRespVO; -import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyOperationsVO; -import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -// TODO @fan:convert 可以考虑去掉,使用 BeanUtils.copy 替代 -/** - * ai image convert - * - * @author fansili - * @time 2024/4/18 16:39 - * @since 1.0 - */ -@Mapper -public interface AiImageConvert { - - AiImageConvert INSTANCE = Mappers.getMapper(AiImageConvert.class); - - /** - * 转换 - AiImageDallDrawingRespVO - * - * @param req - * @return - */ - AiImageDallRespVO convertAiImageDallDrawingRespVO(AiImageDO req); - - /** - * 转换 - AiImageDallDrawingRespVO - * - * @param req - * @return - */ - AiImageDallRespVO convertAiImageDallDrawingRespVO(AiImageDallReqVO req); - - /** - * 转换 - AiImageListRespVO - * - * @param list - * @return - */ - List convertAiImageListRespVO(List list); - - /** - * 转换 - AiImageListRespVO - * - * @param aiImageDO - * @return - */ - AiImageListRespVO convertAiImageListRespVO(AiImageDO aiImageDO); - - /** - * 转换 - AiImageMidjourneyOperationsVO - * - * @param component - * @return - */ - AiImageMidjourneyOperationsVO convertAiImageMidjourneyOperationsVO(MidjourneyMessage.Component component); - - /** - * 转换 - AiImageDO - * - * @param req - * @return - */ - AiImageDO convertAiImageDO(AiImageDallReqVO req); -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/midjourneyHandler/YuDaoMidjourneyMessageHandler.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/midjourneyHandler/YuDaoMidjourneyMessageHandler.java index 6235a9bd7..0568bbec6 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/midjourneyHandler/YuDaoMidjourneyMessageHandler.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/midjourneyHandler/YuDaoMidjourneyMessageHandler.java @@ -2,23 +2,19 @@ package cn.iocoder.yudao.module.ai.service.image.midjourneyHandler; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import org.springframework.ai.models.midjourney.MidjourneyMessage; -import org.springframework.ai.models.midjourney.constants.MidjourneyGennerateStatusEnum; -import org.springframework.ai.models.midjourney.webSocket.MidjourneyMessageHandler; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageMidjourneyOperationsVO; -import cn.iocoder.yudao.module.ai.convert.AiImageConvert; import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; import cn.iocoder.yudao.module.ai.dal.mysql.image.AiImageMapper; import cn.iocoder.yudao.module.ai.enums.AiImageStatusEnum; +import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.ai.models.midjourney.MidjourneyMessage; +import org.springframework.ai.models.midjourney.constants.MidjourneyGennerateStatusEnum; +import org.springframework.ai.models.midjourney.webSocket.MidjourneyMessageHandler; import org.springframework.stereotype.Component; -import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; /** * yudao message handler @@ -113,15 +109,16 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { } private List getMidjourneyOperationsList(MidjourneyMessage midjourneyMessage) { - // 为空直接返回 - if (CollUtil.isEmpty(midjourneyMessage.getComponents())) { - return Collections.emptyList(); - } - // 将 component 转成 AiImageMidjourneyOperationsVO - return midjourneyMessage.getComponents().stream() - .map(componentType -> componentType.getComponents().stream() - .map(AiImageConvert.INSTANCE::convertAiImageMidjourneyOperationsVO) - .collect(Collectors.toList())) - .toList().stream().flatMap(List::stream).toList(); +// // 为空直接返回 +// if (CollUtil.isEmpty(midjourneyMessage.getComponents())) { +// return Collections.emptyList(); +// } +// // 将 component 转成 AiImageMidjourneyOperationsVO +// return midjourneyMessage.getComponents().stream() +// .map(componentType -> componentType.getComponents().stream() +// .map(AiImageConvert.INSTANCE::convertAiImageMidjourneyOperationsVO) +// .collect(Collectors.toList())) +// .toList().stream().flatMap(List::stream).toList(); + return null; } }