mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
Merge remote-tracking branch 'origin/master-jdk21-ai' into master-jdk21-ai
This commit is contained in:
@ -49,8 +49,8 @@ public class AiImageDO extends BaseDO {
|
||||
|
||||
// ============ mj 需要字段
|
||||
|
||||
@Schema(description = "用户操作的消息编号(MJ返回)")
|
||||
private String mjMessageId;
|
||||
@Schema(description = "用户操作的Nonce编号(MJ返回)")
|
||||
private String mjNonceId;
|
||||
|
||||
@Schema(description = "用户操作的操作编号(MJ返回)")
|
||||
private String mjOperationId;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.ai.dal.mysql;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@ -17,4 +18,13 @@ import org.springframework.stereotype.Repository;
|
||||
public interface AiImageMapper extends BaseMapperX<AiImageDO> {
|
||||
|
||||
|
||||
/**
|
||||
* 更新 - 根据 messageId
|
||||
*
|
||||
* @param mjNonceId
|
||||
* @param aiImageDO
|
||||
*/
|
||||
default void updateByMjNonce(Long mjNonceId, AiImageDO aiImageDO) {
|
||||
this.update(aiImageDO, new LambdaQueryWrapperX<AiImageDO>().eq(AiImageDO::getMjNonceId, mjNonceId));
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
// 校验 OperateId 是否存在
|
||||
AiImageMidjourneyOperationsVO midjourneyOperationsVO = validateMidjourneyOperationsExists(midjourneyOperations, req.getOperateId());
|
||||
// 校验 messageId
|
||||
validateMessageId(aiImageDO.getMjMessageId(), req.getMessageId());
|
||||
validateMessageId(aiImageDO.getMjNonceId(), req.getMessageId());
|
||||
// 获取 mjOperationName
|
||||
String mjOperationName = midjourneyOperationsVO.getLabel();
|
||||
// 保存一个 image 任务记录
|
||||
@ -222,7 +222,7 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
aiImageDO.setDrawingImageUrl(drawingImageUrl);
|
||||
aiImageDO.setDrawingErrorMessage(drawingErrorMessage);
|
||||
//
|
||||
aiImageDO.setMjMessageId(mjMessageId);
|
||||
aiImageDO.setMjNonceId(mjMessageId);
|
||||
aiImageDO.setMjOperationId(mjOperationId);
|
||||
aiImageDO.setMjOperationName(mjOperationName);
|
||||
aiImageMapper.insert(aiImageDO);
|
||||
|
@ -62,12 +62,11 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler {
|
||||
|
||||
private void errorHandler(MidjourneyMessage midjourneyMessage) {
|
||||
// image 编号
|
||||
Long aiImageId = Long.valueOf(midjourneyMessage.getNonce());
|
||||
Long nonceId = Long.valueOf(midjourneyMessage.getNonce());
|
||||
// 获取 error message
|
||||
String errorMessage = getErrorMessage(midjourneyMessage);
|
||||
aiImageMapper.updateById(
|
||||
aiImageMapper.updateByMjNonce(nonceId,
|
||||
new AiImageDO()
|
||||
.setId(aiImageId)
|
||||
.setDrawingErrorMessage(errorMessage)
|
||||
.setDrawingStatus(AiImageDrawingStatusEnum.FAIL.getStatus())
|
||||
);
|
||||
@ -83,7 +82,8 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler {
|
||||
|
||||
private void successHandler(MidjourneyMessage midjourneyMessage) {
|
||||
// 获取id
|
||||
Long aiImageId = Long.valueOf(midjourneyMessage.getNonce());
|
||||
Long nonceId = Long.valueOf(midjourneyMessage.getNonce());
|
||||
// TODO @芋艿 这个地方有问题,不能根据 nonce来更新,不返回这个信息(别人获取了 image-xxx-xx 后面一段hash,由于没有mj账号测试,暂不清楚。)
|
||||
// 获取生成 url
|
||||
String imageUrl = null;
|
||||
if (CollUtil.isNotEmpty(midjourneyMessage.getAttachments())) {
|
||||
@ -102,12 +102,11 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler {
|
||||
// 获取 midjourneyOperations
|
||||
List<AiImageMidjourneyOperationsVO> midjourneyOperations = getMidjourneyOperationsList(midjourneyMessage);
|
||||
// 更新数据库
|
||||
aiImageMapper.updateById(
|
||||
aiImageMapper.updateByMjNonce(nonceId,
|
||||
new AiImageDO()
|
||||
.setId(aiImageId)
|
||||
.setDrawingImageUrl(imageUrl)
|
||||
.setDrawingStatus(drawingStatusEnum == null ? null : drawingStatusEnum.getStatus())
|
||||
.setMjMessageId(midjourneyMessage.getId())
|
||||
.setMjNonceId(midjourneyMessage.getId())
|
||||
.setMjOperations(JsonUtils.toJsonString(midjourneyOperations))
|
||||
);
|
||||
}
|
||||
|
@ -20,5 +20,5 @@ Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"prompt": "Cute cartoon style mobile game scene, a colorful camping car with an outdoor table and chairs next to it on the road in a spring forest, the simple structure of the camper van, soft lighting, C4D rendering, 3d model in the style of a cartoon, cute shape, a pastel color scheme, closeup view from the side angle, high resolution, bright colors, a happy atmosphere. --ar 1:2 --v 6.0"
|
||||
"prompt": "Cute cartoon style mobile game scene, a colorful camping car with an outdoor table and chairs next to it on the road in a spring forest, the simple structure of the camper van, soft lighting, C4D rendering, 3d model in the style of a cartoon, cute shape, a pastel color scheme, closeup view from the side angle, high resolution, bright colors, a happy atmosphere."
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
{
|
||||
"type": 2,
|
||||
"application_id": "936929561302675456",
|
||||
"guild_id": "1237948819677904956",
|
||||
"channel_id": "1237948819677904960",
|
||||
"session_id": "4bdb0c32158f625bbd7f0a54bfbb54aa",
|
||||
"data": {
|
||||
"version": "1237876415471554623",
|
||||
"id": "938956540159881230",
|
||||
"name": "imagine",
|
||||
"type": 1,
|
||||
"options": [
|
||||
{
|
||||
"type": 3,
|
||||
"name": "prompt",
|
||||
"value": "哈哈哈"
|
||||
}
|
||||
],
|
||||
"application_command": {
|
||||
"id": "938956540159881230",
|
||||
"type": 1,
|
||||
"application_id": "936929561302675456",
|
||||
"version": "1237876415471554623",
|
||||
"name": "imagine",
|
||||
"description": "Create images with Midjourney",
|
||||
"options": [
|
||||
{
|
||||
"type": 3,
|
||||
"name": "prompt",
|
||||
"description": "The prompt to imagine",
|
||||
"required": true,
|
||||
"description_localized": "The prompt to imagine",
|
||||
"name_localized": "prompt"
|
||||
}
|
||||
],
|
||||
"dm_permission": true,
|
||||
"contexts": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"integration_types": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"global_popularity_rank": 1,
|
||||
"description_localized": "Create images with Midjourney",
|
||||
"name_localized": "imagine"
|
||||
},
|
||||
"attachments": []
|
||||
},
|
||||
"nonce": "1238062212925358080",
|
||||
"analytics_location": "slash_ui"
|
||||
}
|
Reference in New Issue
Block a user