|
@@ -272,18 +272,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
param.put("accountFilter",MapUtil.builder(new HashMap<String,Object>())
|
|
param.put("accountFilter",MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("instanceId",accountWithMinUsage).build());
|
|
.put("instanceId",accountWithMinUsage).build());
|
|
|
Object customId = param.get("customId");
|
|
Object customId = param.get("customId");
|
|
|
- if (customId != null && !customId.toString().contains("upsample") && !action.equals("modal")){
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ userSubmitLimit(user,action,customId);
|
|
|
}
|
|
}
|
|
|
url = url + getActionUrl(action);
|
|
url = url + getActionUrl(action);
|
|
|
param.put("notifyHook",midjourneyHost +(EnvCommonService.active.equals(envCommonService.getEnv()) ? "/8081":"/8082") + "/api/applets/midjourney/notifyHook");
|
|
param.put("notifyHook",midjourneyHost +(EnvCommonService.active.equals(envCommonService.getEnv()) ? "/8081":"/8082") + "/api/applets/midjourney/notifyHook");
|
|
@@ -367,6 +356,36 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
default: throw new IllegalArgumentException("Unknown action: " + action);
|
|
default: throw new IllegalArgumentException("Unknown action: " + action);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户生图次数限制
|
|
|
|
|
+ */
|
|
|
|
|
+ public void userSubmitLimit(MidjourneyUser user,String action,Object customId) {
|
|
|
|
|
+ if (StringUtils.equals("modal",action)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (customId != null && customId.toString().contains("upsample")) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ //24小时内提交次数超过200次 拉黑
|
|
|
|
|
+ user.setIsBlack(true);
|
|
|
|
|
+ midjourneyUserMapper.updateById(user);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //用户30秒内只能提交一次
|
|
|
|
|
+ if (redisService.hasKey(RedisService.key.MIDJOURNEY_USER_SUBMIT.getName() + user.getId())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("操作太快了,请等待"+redisService.getExpire(RedisService.key.MIDJOURNEY_USER_SUBMIT.getName() + user.getId())+"秒后再试.为了防止爬虫,让大家有个良好的使用环境,relax模式命令最短时间间隔30秒,fast模式最短间隔5秒");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ redisService.set(RedisService.key.MIDJOURNEY_USER_SUBMIT.getName() + user.getId(), 1L, 30L);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
public List<MidjourneyUserConversation> listConversationByIds(Integer mode, List<Long> ids) {
|
|
public List<MidjourneyUserConversation> listConversationByIds(Integer mode, List<Long> ids) {
|
|
|
List<MidjourneyUserConversation> list = new ArrayList<>();
|
|
List<MidjourneyUserConversation> list = new ArrayList<>();
|