|
@@ -6,21 +6,25 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
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.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.ChatgptSessionMapper;
|
|
import com.cyksj.mapper.ChatgptSessionMapper;
|
|
|
import com.cyksj.model.dto.ChatGptChangePasswordDto;
|
|
import com.cyksj.model.dto.ChatGptChangePasswordDto;
|
|
|
import com.cyksj.model.entity.ChatgptSession;
|
|
import com.cyksj.model.entity.ChatgptSession;
|
|
|
|
|
+import com.cyksj.model.entity.SysConfig;
|
|
|
import com.cyksj.model.excel.ExcelGptMirrorAccountData;
|
|
import com.cyksj.model.excel.ExcelGptMirrorAccountData;
|
|
|
import com.cyksj.model.views.ChatgptCarSessionView;
|
|
import com.cyksj.model.views.ChatgptCarSessionView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
|
import com.cyksj.service.mail.YhMailService;
|
|
import com.cyksj.service.mail.YhMailService;
|
|
|
|
|
+import com.cyksj.service.sys.SysConfigService;
|
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
@@ -58,6 +62,8 @@ public class CmsGptCarController {
|
|
|
|
|
|
|
|
private final YhMailService yhMailService;
|
|
private final YhMailService yhMailService;
|
|
|
|
|
|
|
|
|
|
+ private final SysConfigService sysConfigService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取镜像车队账号列表
|
|
* 获取镜像车队账号列表
|
|
|
*/
|
|
*/
|
|
@@ -89,6 +95,7 @@ public class CmsGptCarController {
|
|
|
if (selectCount > 0) {
|
|
if (selectCount > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
|
|
throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ refresh(chatgptSession.getId());
|
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|
|
@@ -153,6 +160,7 @@ public class CmsGptCarController {
|
|
|
chatgptSession.setCarId("P" + chatgptSession.getId());
|
|
chatgptSession.setCarId("P" + chatgptSession.getId());
|
|
|
chatgptSession.setCarName("P" + chatgptSession.getId());
|
|
chatgptSession.setCarName("P" + chatgptSession.getId());
|
|
|
}
|
|
}
|
|
|
|
|
+ refresh(chatgptSession.getId());
|
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
|
|
|
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
@@ -181,6 +189,7 @@ public class CmsGptCarController {
|
|
|
if (code == 1) {
|
|
if (code == 1) {
|
|
|
//修改密码
|
|
//修改密码
|
|
|
chatgptSession.setPassword(chatGptChangePasswordDto.getPassword());
|
|
chatgptSession.setPassword(chatGptChangePasswordDto.getPassword());
|
|
|
|
|
+ refresh(chatgptSession.getId());
|
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
chatgptSessionMapper.updateById(chatgptSession);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
} else {
|
|
} else {
|
|
@@ -198,6 +207,7 @@ public class CmsGptCarController {
|
|
|
if (dbChatSession != null) {
|
|
if (dbChatSession != null) {
|
|
|
String gptSession = chatGptAccountService.getGptSession(dbChatSession.getEmail(), dbChatSession.getPassword());
|
|
String gptSession = chatGptAccountService.getGptSession(dbChatSession.getEmail(), dbChatSession.getPassword());
|
|
|
dbChatSession.setOfficialSession(gptSession);
|
|
dbChatSession.setOfficialSession(gptSession);
|
|
|
|
|
+ refresh(dbChatSession.getId());
|
|
|
chatgptSessionMapper.updateById(dbChatSession);
|
|
chatgptSessionMapper.updateById(dbChatSession);
|
|
|
}
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
@@ -254,4 +264,17 @@ public class CmsGptCarController {
|
|
|
String linkUrl = yhMailService.readResetPwdResetLink(account);
|
|
String linkUrl = yhMailService.readResetPwdResetLink(account);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(linkUrl);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(linkUrl);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private void refresh(Long id){
|
|
|
|
|
+ try {
|
|
|
|
|
+ SysConfig one = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, "mirror_gpt_domain"));
|
|
|
|
|
+ List<String> array = new JSONArray(one.getSysValue()).toList(String.class);
|
|
|
|
|
+ array.forEach((domain)->{
|
|
|
|
|
+ String url = domain + "/backend-api/car/refresh?carId=" + id;
|
|
|
|
|
+ HttpUtil.get(url);
|
|
|
|
|
+ });
|
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
|
+ log.error("刷新车队token异常:{}", StringUtil.getErrorText(e));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|