|
|
@@ -346,50 +346,22 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SubmitResult submitSeed(MidjourneyUser user, Integer mode,String taskId, String botType) throws Exception {
|
|
|
- //SubmitResult result = seed(user.getMode(),"seed", taskId);
|
|
|
- //return saveConversation(user.getId(), user.getMode(), result,"SEED", StringUtils.EMPTY, botType);
|
|
|
- return null;
|
|
|
+ public SubmitResult submitSeed(MidjourneyUser user, String taskId, String botType) throws Exception {
|
|
|
+ return seed(taskId);
|
|
|
}
|
|
|
|
|
|
- //private SubmitResult seed(Integer mode, String seed, Long taskId) {
|
|
|
- // String url = "";
|
|
|
- // if (mode == 1) {
|
|
|
- // url = FAST_HOST;
|
|
|
- // } else if (mode == 2) {
|
|
|
- // url = RELAX_HOST;
|
|
|
- // }
|
|
|
- // url = url + String.format("/mj/task/%d/image-seed", taskId);
|
|
|
- // String body = HttpRequest.get(url).header("Authorization", FAST_TOKEN).execute().body();
|
|
|
- // log.info("seed body:{}", body);
|
|
|
- // SubmitResult submitResult = Jsons.parseObject(body, SubmitResult.class);
|
|
|
- // int code = submitResult.getCode();
|
|
|
- // if (code != 1 && code != 21 && code != 22) {
|
|
|
- // if (code == 3) {
|
|
|
- // if(mode == 2 && StringUtils.isNotBlank(accountWithMinUsage)){
|
|
|
- // redisService.hdel(RedisService.key.MIDJOURNEY_ACCOUNT.getName(),accountWithMinUsage);
|
|
|
- // String finalAccountWithMinUsage = accountWithMinUsage;
|
|
|
- // TASK_EXECUTOR.execute(() -> {
|
|
|
- // MidjourneyAccount account = midjourneyAccountService.getOne(Wrappers.lambdaQuery(MidjourneyAccount.class).eq(MidjourneyAccount::getInstanceId, finalAccountWithMinUsage).last("limit 1"));
|
|
|
- // midjourneyAccountService.updateStatus(account.getId());
|
|
|
- // });
|
|
|
- // }
|
|
|
- // throw BusinessRuntimeException.getInstance("账号不存在");
|
|
|
- // }
|
|
|
- // if (code == 4) {
|
|
|
- // throw BusinessRuntimeException.getInstance(submitResult.getDescription());
|
|
|
- // }
|
|
|
- // if (code == 24) {
|
|
|
- // JSONObject jsonObject = JSONUtil.parseObj(submitResult.getResult());
|
|
|
- // throw BusinessRuntimeException.getInstance("prompt包含敏感词:"+jsonObject.getStr("bannedWord"));
|
|
|
- // }
|
|
|
- // throw BusinessRuntimeException.getInstance("队列已满,请稍后重试");
|
|
|
- // }
|
|
|
- // if (StringUtils.isNotBlank(accountWithMinUsage) && mode == 2) {
|
|
|
- // submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
- // }
|
|
|
- // return submitResult;
|
|
|
- //}
|
|
|
+ private SubmitResult seed(String taskId) throws Exception {
|
|
|
+ String url = RELAX_HOST + String.format("/mj/task/%s/image-seed", taskId);
|
|
|
+ String body = HttpRequest.get(url).header("Authorization", RELAX_TOKEN).execute().body();
|
|
|
+ log.info("seed body:{}", body);
|
|
|
+ SubmitResult submitResult = Jsons.parseObject(body, SubmitResult.class);
|
|
|
+ int code = submitResult.getCode();
|
|
|
+ if (code != 1) {
|
|
|
+ log.error("seed获取失败 taskId:{}, err:{}", taskId, submitResult.getDescription());
|
|
|
+ throw BusinessRuntimeException.getInstance("seed获取失败");
|
|
|
+ }
|
|
|
+ return submitResult;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 恢复次数
|