diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java index 9e75cb436..6cf8a80e7 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/image/AiImageMapper.java @@ -24,7 +24,8 @@ public interface AiImageMapper extends BaseMapperX { * @param aiImageDO */ default void updateByMjNonce(Long mjNonceId, AiImageDO aiImageDO) { - this.update(aiImageDO, new LambdaQueryWrapperX().eq(AiImageDO::getMjNonceId, mjNonceId)); +// this.update(aiImageDO, new LambdaQueryWrapperX().eq(AiImageDO::getMjNonceId, mjNonceId)); + return; } } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java index 1d4e24764..68543e50b 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageService.java @@ -26,7 +26,7 @@ public interface AiImageService { * @param id * @return */ - AiImageListRespVO get(Long id); + AiImageListRespVO getMy(Long id); /** * ai绘画 - dall2/dall3 绘画 @@ -54,7 +54,8 @@ public interface AiImageService { * 删除 - image 记录 * * @param id + * @param loginUserId */ - void delete(Long id); + void deleteMy(Long id, Long loginUserId); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java index 18b1ef0ea..87e0fa2ff 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java @@ -39,6 +39,9 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + + // TODO @fan:注释优化下哈 /** * ai 作图 @@ -105,7 +108,7 @@ public class AiImageServiceImpl implements AiImageService { // TODO @fan:1)返回 DO;VO 的翻译,交给 Controller;2)还有,使用 BeanUtils 替代哈 @Override - public AiImageListRespVO get(Long id) { + public AiImageListRespVO getMy(Long id) { AiImageDO aiImageDO = aiImageMapper.selectById(id); return AiImageConvert.INSTANCE.convertAiImageListRespVO(aiImageDO); } @@ -172,34 +175,37 @@ public class AiImageServiceImpl implements AiImageService { @Transactional(rollbackFor = Exception.class) @Override public void midjourneyOperate(AiImageMidjourneyOperateReqVO req) { - // 校验是否存在 - AiImageDO aiImageDO = validateExists(req.getId()); - // 获取 midjourneyOperations - List midjourneyOperations = getMidjourneyOperations(aiImageDO); - // 校验 OperateId 是否存在 - AiImageMidjourneyOperationsVO midjourneyOperationsVO = validateMidjourneyOperationsExists(midjourneyOperations, req.getOperateId()); - // 校验 messageId - validateMessageId(aiImageDO.getMjNonceId(), req.getMessageId()); - // 获取 mjOperationName - String mjOperationName = midjourneyOperationsVO.getLabel(); - // 保存一个 image 任务记录 - // todo -// doSave(aiImageDO.getPrompt(), aiImageDO.getSize(), aiImageDO.getModel(), -// null, null, AiImageStatusEnum.SUBMIT, null, -// req.getMessageId(), req.getOperateId(), mjOperationName); - // 提交操作 - midjourneyInteractionsApi.reRoll( - new ReRollReq() - .setCustomId(req.getOperateId()) - .setMessageId(req.getMessageId()) - ); +// // 校验是否存在 +// AiImageDO aiImageDO = validateExists(req.getId()); +// // 获取 midjourneyOperations +// List midjourneyOperations = getMidjourneyOperations(aiImageDO); +// // 校验 OperateId 是否存在 +// AiImageMidjourneyOperationsVO midjourneyOperationsVO = validateMidjourneyOperationsExists(midjourneyOperations, req.getOperateId()); +// // 校验 messageId +// validateMessageId(aiImageDO.getMjNonceId(), req.getMessageId()); +// // 获取 mjOperationName +// String mjOperationName = midjourneyOperationsVO.getLabel(); +// // 保存一个 image 任务记录 +// // todo +//// doSave(aiImageDO.getPrompt(), aiImageDO.getSize(), aiImageDO.getModel(), +//// null, null, AiImageStatusEnum.SUBMIT, null, +//// req.getMessageId(), req.getOperateId(), mjOperationName); +// // 提交操作 +// midjourneyInteractionsApi.reRoll( +// new ReRollReq() +// .setCustomId(req.getOperateId()) +// .setMessageId(req.getMessageId()) +// ); } // TODO @fan:1)需要校验存在;2)需要校验属于我; @Override - public void delete(Long id) { + public void deleteMy(Long id, Long loginUserId) { // 校验记录是否存在 AiImageDO aiImageDO = validateExists(id); + if (!aiImageDO.getUserId().equals(loginUserId)) { + throw exception(ErrorCodeConstants.AI_IMAGE_NOT_CREATE_USER); + } // 删除记录 aiImageMapper.deleteById(id); } @@ -221,10 +227,11 @@ public class AiImageServiceImpl implements AiImageService { private List getMidjourneyOperations(AiImageDO aiImageDO) { - if (StrUtil.isBlank(aiImageDO.getMjOperations())) { - return Collections.emptyList(); - } - return JsonUtils.parseArray(aiImageDO.getMjOperations(), AiImageMidjourneyOperationsVO.class); +// if (StrUtil.isBlank(aiImageDO.getMjOperations())) { +// return Collections.emptyList(); +// } +// return JsonUtils.parseArray(aiImageDO.getMjOperations(), AiImageMidjourneyOperationsVO.class); + return null; } private AiImageDO validateExists(Long id) { 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 7b95b968e..6235a9bd7 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 @@ -96,9 +96,10 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { drawingStatusEnum = AiImageStatusEnum.COMPLETE; } else if (MidjourneyGennerateStatusEnum.IN_PROGRESS.getStatus().equals(generateStatus)) { drawingStatusEnum = AiImageStatusEnum.IN_PROGRESS; - } else if (MidjourneyGennerateStatusEnum.WAITING.getStatus().equals(generateStatus)) { - drawingStatusEnum = AiImageStatusEnum.WAITING; } +// else if (MidjourneyGennerateStatusEnum.WAITING.getStatus().equals(generateStatus)) { +// drawingStatusEnum = AiImageStatusEnum.WAITING; +// } // 获取 midjourneyOperations List midjourneyOperations = getMidjourneyOperationsList(midjourneyMessage); // 更新数据库 @@ -106,8 +107,8 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { new AiImageDO() .setOriginalPicUrl(imageUrl) .setStatus(drawingStatusEnum == null ? null : drawingStatusEnum.getStatus()) - .setMjNonceId(midjourneyMessage.getId()) - .setMjOperations(JsonUtils.toJsonString(midjourneyOperations)) +// .setMjNonceId(midjourneyMessage.getId()) +// .setMjOperations(JsonUtils.toJsonString(midjourneyOperations)) ); }