mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 09:30:05 +08:00
【解决todo】删除 mj 相关字段,抽离到 drawRequest 和 drwaResponse
This commit is contained in:
parent
ed372cffc7
commit
f347b15a1e
@ -24,7 +24,8 @@ public interface AiImageMapper extends BaseMapperX<AiImageDO> {
|
||||
* @param aiImageDO
|
||||
*/
|
||||
default void updateByMjNonce(Long mjNonceId, AiImageDO aiImageDO) {
|
||||
this.update(aiImageDO, new LambdaQueryWrapperX<AiImageDO>().eq(AiImageDO::getMjNonceId, mjNonceId));
|
||||
// this.update(aiImageDO, new LambdaQueryWrapperX<AiImageDO>().eq(AiImageDO::getMjNonceId, mjNonceId));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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<AiImageMidjourneyOperationsVO> 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<AiImageMidjourneyOperationsVO> 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<AiImageMidjourneyOperationsVO> 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) {
|
||||
|
@ -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<AiImageMidjourneyOperationsVO> 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))
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user