|
@@ -6,7 +6,6 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.URLUtil;
|
|
import cn.hutool.core.util.URLUtil;
|
|
|
-import cn.hutool.db.sql.SqlBuilder;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
@@ -24,7 +23,6 @@ import com.yhlxj.dao.mapper.GroupsRelationMapper;
|
|
|
import com.yhlxj.dao.mapper.midjourney.*;
|
|
import com.yhlxj.dao.mapper.midjourney.*;
|
|
|
import com.yhlxj.dao.model.dto.*;
|
|
import com.yhlxj.dao.model.dto.*;
|
|
|
import com.yhlxj.dao.model.entity.*;
|
|
import com.yhlxj.dao.model.entity.*;
|
|
|
-import com.yhlxj.dao.model.enums.WsMessageTypeEnum;
|
|
|
|
|
import com.yhlxj.dao.model.response.SubmitResult;
|
|
import com.yhlxj.dao.model.response.SubmitResult;
|
|
|
import com.yhlxj.redis.RedisService;
|
|
import com.yhlxj.redis.RedisService;
|
|
|
import com.yhlxj.service.common.EnvCommonService;
|
|
import com.yhlxj.service.common.EnvCommonService;
|
|
@@ -32,7 +30,6 @@ import com.yhlxj.service.midjourney.MidjourneyAccountService;
|
|
|
import com.yhlxj.service.midjourney.MidjourneyService;
|
|
import com.yhlxj.service.midjourney.MidjourneyService;
|
|
|
import com.yhlxj.service.midjourney.MidjourneyUserSettingsService;
|
|
import com.yhlxj.service.midjourney.MidjourneyUserSettingsService;
|
|
|
import com.yhlxj.util.COSUtil;
|
|
import com.yhlxj.util.COSUtil;
|
|
|
-import com.yhlxj.web.wss.WssSession;
|
|
|
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -55,13 +52,10 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Path;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
-import static com.yhlxj.web.wss.MidjourneyServerEndpoint.WSS_SESSION_MAP;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author zwhui
|
|
* @author zwhui
|
|
|
* @date 2024/4/23 15:44
|
|
* @date 2024/4/23 15:44
|
|
@@ -489,7 +483,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
userSubmitLimit(user,action,param.get("customId"),again);
|
|
userSubmitLimit(user,action,param.get("customId"),again);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- SubmitResult submitResult = submit2MjProxy(mode, action, param);
|
|
|
|
|
|
|
+ SubmitResult submitResult = submit2MjProxy(action, param);
|
|
|
//submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
//submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
int code = submitResult.getCode();
|
|
int code = submitResult.getCode();
|
|
|
if (code == 23){
|
|
if (code == 23){
|
|
@@ -548,7 +542,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
return submit(user, mode, action, instanceId, param, true, num);
|
|
return submit(user, mode, action, instanceId, param, true, num);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private SubmitResult submit2MjProxy(Integer mode, String action, Map<String, Object> param) throws Exception {
|
|
|
|
|
|
|
+ private SubmitResult submit2MjProxy(String action, Map<String, Object> param) throws Exception {
|
|
|
String host = midjourneyHost;
|
|
String host = midjourneyHost;
|
|
|
if (EnvCommonService.active_prd.equals(envCommonService.getEnv())){
|
|
if (EnvCommonService.active_prd.equals(envCommonService.getEnv())){
|
|
|
host = "http://172.17.0.1:8082/applets/midjourney/notifyHook";
|
|
host = "http://172.17.0.1:8082/applets/midjourney/notifyHook";
|
|
@@ -556,7 +550,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
host = host + "/8083/api/applets/midjourney/notifyHook";
|
|
host = host + "/8083/api/applets/midjourney/notifyHook";
|
|
|
}
|
|
}
|
|
|
param.put("notifyHook",host);
|
|
param.put("notifyHook",host);
|
|
|
- HttpRequest request = HttpRequest.post(apiUrl + getActionUrl(action,mode)).header("mj-api-secret", RELAX_TOKEN).body(Jsons.toJson(param));
|
|
|
|
|
|
|
+ HttpRequest request = HttpRequest.post(apiUrl + getActionUrl(action)).header("mj-api-secret", RELAX_TOKEN).body(Jsons.toJson(param));
|
|
|
String body = request.execute().body();
|
|
String body = request.execute().body();
|
|
|
log.info("action body:{}", body);
|
|
log.info("action body:{}", body);
|
|
|
return Jsons.parseObject(body, SubmitResult.class);
|
|
return Jsons.parseObject(body, SubmitResult.class);
|
|
@@ -666,21 +660,20 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
throw BusinessRuntimeException.getInstance("获取账号失败");
|
|
throw BusinessRuntimeException.getInstance("获取账号失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- private String getActionUrl(String action,Integer mode) {
|
|
|
|
|
- String url = mode == 1 ? "/mj-fast" : "/mj-relax";
|
|
|
|
|
|
|
+ private String getActionUrl(String action) {
|
|
|
switch (action) {
|
|
switch (action) {
|
|
|
case "imagine":
|
|
case "imagine":
|
|
|
- return url + "/mj/submit/imagine";
|
|
|
|
|
|
|
+ return "/mj/submit/imagine";
|
|
|
case "action":
|
|
case "action":
|
|
|
- return url + "/mj/submit/action";
|
|
|
|
|
|
|
+ return "/mj/submit/action";
|
|
|
case "describe":
|
|
case "describe":
|
|
|
- return url + "/mj/submit/describe";
|
|
|
|
|
|
|
+ return "/mj/submit/describe";
|
|
|
case "blend":
|
|
case "blend":
|
|
|
- return url + "/mj/submit/blend";
|
|
|
|
|
|
|
+ return "/mj/submit/blend";
|
|
|
case "modal":
|
|
case "modal":
|
|
|
- return url + "/mj/submit/modal";
|
|
|
|
|
|
|
+ return "/mj/submit/modal";
|
|
|
case "shorten":
|
|
case "shorten":
|
|
|
- return url + "/mj/submit/shorten";
|
|
|
|
|
|
|
+ return "/mj/submit/shorten";
|
|
|
default: throw new IllegalArgumentException("Unknown action: " + action);
|
|
default: throw new IllegalArgumentException("Unknown action: " + action);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|