|
|
@@ -1,6 +1,8 @@
|
|
|
package com.cyksj.web.controller.manage.account;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
@@ -8,6 +10,7 @@ import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.GoogleGenerator;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
@@ -17,6 +20,7 @@ import com.cyksj.model.excel.ExcelGptMirrorAccountData;
|
|
|
import com.cyksj.model.views.ChatgptCarSessionView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
|
+import com.cyksj.service.mail.YhMailService;
|
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
@@ -29,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/** admin/镜像车队账号管理
|
|
|
* 项目名: yhlxj
|
|
|
@@ -51,6 +56,8 @@ public class CmsGptCarController {
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
+ private final YhMailService yhMailService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取镜像车队账号列表
|
|
|
*/
|
|
|
@@ -185,4 +192,59 @@ public class CmsGptCarController {
|
|
|
});
|
|
|
EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelGptMirrorAccountData.class, dataList, "gpt镜像账号", "gpt镜像账号", ExcelTypeEnum.XLS, null);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看gpt验证码
|
|
|
+ */
|
|
|
+ @GetMapping("/get/account/verifyCode")
|
|
|
+ public Result<String> getAccountVerifyCode(Long id) {
|
|
|
+ ChatgptSession chatgptSession = chatgptSessionMapper.selectById(id);
|
|
|
+ String apiSecret = chatgptSession.getApiSecret();
|
|
|
+ if (StrUtil.isEmpty(apiSecret)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("双重验证密钥为空");
|
|
|
+ }
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ int second = now.second();
|
|
|
+ if (second < 30 && 30 - second < 3) {
|
|
|
+ ThreadUtil.sleep(30 - second + 1, TimeUnit.SECONDS);
|
|
|
+ } else if (second > 30 && 60 - second < 3) {
|
|
|
+ ThreadUtil.sleep(60 - second + 1, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ JSONObject re = new JSONObject();
|
|
|
+ try {
|
|
|
+ long code = GoogleGenerator.getCode(apiSecret, now.getTime());
|
|
|
+ sb.append(code);
|
|
|
+ while (sb.length() < 6) {
|
|
|
+ sb.insert(0, 0);
|
|
|
+ }
|
|
|
+ re.putOpt("code", sb.toString());
|
|
|
+ int nowSecond = DateTime.now().second();
|
|
|
+ int time = 0;
|
|
|
+ if (nowSecond < 30) {
|
|
|
+ time = 30 - nowSecond;
|
|
|
+ } else {
|
|
|
+ time = 60 - nowSecond;
|
|
|
+ }
|
|
|
+ re.putOpt("time", time);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取GPT重置密码链接
|
|
|
+ */
|
|
|
+ @GetMapping("/read/resetPassword/link")
|
|
|
+ public Result<String> readResetPwdResetLink(Long id) {
|
|
|
+ ChatgptSession chatgptSession = chatgptSessionMapper.selectById(id);
|
|
|
+ String account = chatgptSession.getEmail();
|
|
|
+ String relateEmail = chatgptSession.getRelateEmail();
|
|
|
+ if (StrUtil.isNotEmpty(relateEmail)) {
|
|
|
+ account = relateEmail;
|
|
|
+ }
|
|
|
+ String linkUrl = yhMailService.readResetPwdResetLink(account);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(linkUrl);
|
|
|
+ }
|
|
|
}
|