|
|
@@ -10,7 +10,6 @@ import com.cyksj.mapper.MidjourneyUserMapper;
|
|
|
import com.cyksj.model.entity.MidjourneyUser;
|
|
|
import com.cyksj.model.entity.MidjourneyUserConversation;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
-import com.cyksj.service.midjourney.MidjourneyAccountService;
|
|
|
import com.cyksj.service.midjourney.MidjourneyService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
@@ -90,13 +89,13 @@ public class MidjourneyController {
|
|
|
public Long checkUserLimit(MidjourneyUser user){
|
|
|
Long num = 0L;
|
|
|
if (user.getExpireTime().before(new Date())){
|
|
|
- return num;
|
|
|
+ throw BusinessRuntimeException.getInstance("账号已过期");
|
|
|
}
|
|
|
if (user.getMode() == 1){
|
|
|
num = redisService.decr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + user.getId(), 1L);
|
|
|
if (num < 0) {
|
|
|
user.setMode(2);
|
|
|
- num = redisService.incr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + user.getId(), 1L);
|
|
|
+ redisService.incr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + user.getId(), 1L);
|
|
|
}
|
|
|
}
|
|
|
if (user.getMode() == 2){
|
|
|
@@ -104,7 +103,7 @@ public class MidjourneyController {
|
|
|
if (relax != null){
|
|
|
num = redisService.decr(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + user.getId(), 1L);
|
|
|
if (num < 0){
|
|
|
- num = redisService.incr(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + user.getId(), 1L);
|
|
|
+ redisService.incr(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + user.getId(), 1L);
|
|
|
}
|
|
|
}else {
|
|
|
num = null;
|
|
|
@@ -163,7 +162,7 @@ public class MidjourneyController {
|
|
|
log.info("提交Imagine任务,提示:{},base64数组长度:{}",submitImagineDTO.getPrompt(),submitImagineDTO.getBase64Array());
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|
|
|
@@ -185,7 +184,7 @@ public class MidjourneyController {
|
|
|
log.info("提交Describe任务");
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|
|
|
@@ -207,7 +206,7 @@ public class MidjourneyController {
|
|
|
log.info("提交Blend任务 dimensions:{},base64数组长度:{}", submitBlendDTO.getDimensions(), submitBlendDTO.getBase64Array().size());
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|
|
|
@@ -229,7 +228,7 @@ public class MidjourneyController {
|
|
|
log.info("提交Modal任务,taskId:{},提示:{},base64数组长度:{}",submitModalDTO.getTaskId(),submitModalDTO.getPrompt(),submitModalDTO.getMaskBase64());
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|
|
|
@@ -251,7 +250,7 @@ public class MidjourneyController {
|
|
|
log.info("提交Shorten任务 提示词:{}",submitShortenDTO.getPrompt());
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|
|
|
@@ -273,7 +272,7 @@ public class MidjourneyController {
|
|
|
log.info("任务id:{},执行动作:{}",actionDTO.getTaskId(),actionDTO.getCustomId());
|
|
|
MidjourneyUser user = getUser();
|
|
|
Long num = checkUserLimit(user);
|
|
|
- if (num != null && num <= 0){
|
|
|
+ if (num != null && num < 0){
|
|
|
throw BusinessRuntimeException.getInstance("次数已用完");
|
|
|
}
|
|
|
MidjourneyUserConversation conversation;
|