|
|
@@ -82,7 +82,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (CollectionUtil.isNotEmpty(base64Array)) {
|
|
|
imagineParam.put("base64Array", base64Array);
|
|
|
}
|
|
|
- SubmitResult result = submit(user.getMode(),"imagine", null,imagineParam);
|
|
|
+ SubmitResult result = submit(user,"imagine", null,imagineParam);
|
|
|
if (user.getMode() == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
@@ -115,7 +115,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
.put("state", user.getId())
|
|
|
.put("base64", base64)
|
|
|
.build();
|
|
|
- SubmitResult result = submit(user.getMode(),"describe", null, param);
|
|
|
+ SubmitResult result = submit(user,"describe", null, param);
|
|
|
if (user.getMode() == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
@@ -131,7 +131,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (dimensions != null) {
|
|
|
param.put("dimensions", dimensions);
|
|
|
}
|
|
|
- SubmitResult result = submit(user.getMode(),"blend", null, param);
|
|
|
+ SubmitResult result = submit(user,"blend", null, param);
|
|
|
if (user.getMode() == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
@@ -150,7 +150,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (StringUtils.isNotBlank(maskBase64)) {
|
|
|
param.put("maskBase64", maskBase64);
|
|
|
}
|
|
|
- SubmitResult result = submit(user.getMode(),"modal", null, param);
|
|
|
+ SubmitResult result = submit(user,"modal", null, param);
|
|
|
if (user.getMode() == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
@@ -163,7 +163,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
.put("prompt", prompt)
|
|
|
.put("state", user.getId())
|
|
|
.build();
|
|
|
- SubmitResult result = submit(user.getMode(),"shorten", null, param);
|
|
|
+ SubmitResult result = submit(user,"shorten", null, param);
|
|
|
if (user.getMode() == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
@@ -237,7 +237,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
.put("state", user.getId())
|
|
|
.put("customId", customId)
|
|
|
.build();
|
|
|
- SubmitResult result = submit(user.getMode(),"action", conversation.getInstanceId(),param);
|
|
|
+ SubmitResult result = submit(user,"action", conversation.getInstanceId(),param);
|
|
|
if (result.getCode() == 21) {
|
|
|
if (user.getMode() == 2 && modalFlag.get()){
|
|
|
MidjourneyUserConversation modal = submitModal(user, Long.valueOf(result.getResult()), conversation.getPrompt(), null);
|
|
|
@@ -258,9 +258,10 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public SubmitResult submit(Integer mode,String action,Long instanceId, Map<String, Object> param) throws Exception {
|
|
|
+ public SubmitResult submit(MidjourneyUser user,String action,Long instanceId, Map<String, Object> param) throws Exception {
|
|
|
String url = "";
|
|
|
String accountWithMinUsage = "";
|
|
|
+ Integer mode = user.getMode();
|
|
|
if (mode == 1) {
|
|
|
param.put("mode", "FAST");
|
|
|
url = FAST_HOST;
|
|
|
@@ -270,6 +271,16 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
accountWithMinUsage = getAccountWithMinUsage(instanceId);
|
|
|
param.put("accountFilter",MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("instanceId",accountWithMinUsage).build());
|
|
|
+ String key = RedisService.key.MIDJOURNEY_USER_TIME.getName() + user.getId();
|
|
|
+ Object count = redisService.get(key);
|
|
|
+ if (count == null) {
|
|
|
+ redisService.set(key, 1L,RedisService.key.MIDJOURNEY_USER_TIME.getTimeout());
|
|
|
+ }else {
|
|
|
+ if (redisService.incr(key, 1L) > 200) {
|
|
|
+ user.setIsBlack(true);
|
|
|
+ midjourneyUserMapper.updateById(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
url = url + getActionUrl(action);
|
|
|
param.put("notifyHook",midjourneyHost +(EnvCommonService.active.equals(envCommonService.getEnv()) ? "/8081":"/8082") + "/api/applets/midjourney/notifyHook");
|