|
|
@@ -13,7 +13,6 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
|
import com.cyksj.common.util.IoKit;
|
|
|
import com.cyksj.dto.RedisKey;
|
|
|
-import com.cyksj.dto.Result;
|
|
|
import com.cyksj.mapper.AccountMapper;
|
|
|
import com.cyksj.model.entity.Account;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
@@ -124,12 +123,17 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
|
|
|
throw BusinessRuntimeException.getInstance("账号不存在.");
|
|
|
}
|
|
|
if(StringUtils.isBlank(account.getGptRefreshToken())){
|
|
|
+ if (!redisService.setNx(RedisService.key.CHAT_GPT_TOKEN_KEY.getName() + username, username, RedisService.key.CHAT_GPT_TOKEN_KEY.getTimeout())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("正在获取直连token中...");
|
|
|
+ }
|
|
|
String refreshToken = getRefreshToken(account);
|
|
|
if(StringUtils.isBlank(refreshToken)){
|
|
|
+ redisService.del(RedisService.key.CHAT_GPT_TOKEN_KEY.getName() + username);
|
|
|
throw BusinessRuntimeException.getInstance("该账号登录异常.");
|
|
|
}
|
|
|
account.setGptRefreshToken(refreshToken);
|
|
|
accountMapper.updateById(account);
|
|
|
+ redisService.del(RedisService.key.CHAT_GPT_TOKEN_KEY.getName() + username);
|
|
|
return redisService.getStr(RedisKey.CHATGPT_ACCESS_TOKEN + account.getAccount());
|
|
|
}
|
|
|
String accessToken = redisService.getStr(RedisKey.CHATGPT_ACCESS_TOKEN + username);
|