|
|
@@ -907,7 +907,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
synchronized (key.intern()) {
|
|
|
String currentProgressStr = redisService.getStr(key);
|
|
|
int currentProgress = StringUtils.isBlank(currentProgressStr) ? 0 : Integer.parseInt(currentProgressStr);
|
|
|
- if (conversation.getProgressNum() > currentProgress || "FAILURE".equals(conversation.getStatus())) {
|
|
|
+ if (conversation.getProgressNum() > currentProgress) {
|
|
|
redisService.set(key, String.valueOf(conversation.getProgressNum()), RedisService.key.MIDJOURNEY_PROGRESS.getTimeout());
|
|
|
sendProgressToClient(conversation);
|
|
|
}
|
|
|
@@ -995,11 +995,21 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SubmitResult uploadFile(SubmitUploadDTO uploadDTO) throws Exception {
|
|
|
+ public MidjourneyUserConversation uploadFile(SubmitUploadDTO uploadDTO,MidjourneyUser user) throws Exception {
|
|
|
HttpRequest request = HttpRequest.post(RELAX_HOST + "/mj/submit/upload-discord-images").body(Jsons.toJson(uploadDTO));
|
|
|
String body = request.execute().body();
|
|
|
log.info("action body:{}", body);
|
|
|
- return Jsons.parseObject(body, SubmitResult.class);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
+ if (jsonObject.getInt("code") != 1) {
|
|
|
+ throw BusinessRuntimeException.getInstance("action error message:" + jsonObject.getStr("description"));
|
|
|
+ }
|
|
|
+ MidjourneyUserConversation conversation = new MidjourneyUserConversation();
|
|
|
+ conversation.setAction("UPLOAD");
|
|
|
+ conversation.setUserId(user.getId());
|
|
|
+ conversation.setStatus("SUCCESS");
|
|
|
+ conversation.setImageUrl(jsonObject.getJSONArray("result").getStr(0));
|
|
|
+ conversationMapper.insert(conversation);
|
|
|
+ return conversation;
|
|
|
}
|
|
|
|
|
|
|