|
|
@@ -1,8 +1,6 @@
|
|
|
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;
|
|
|
@@ -10,7 +8,6 @@ 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;
|
|
|
@@ -33,7 +30,6 @@ 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
|
|
|
@@ -199,37 +195,13 @@ public class CmsGptCarController {
|
|
|
@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);
|
|
|
+ String account = chatgptSession.getEmail();
|
|
|
+ if (StrUtil.isNotEmpty(chatgptSession.getRelateEmail())) {
|
|
|
+ account = chatgptSession.getRelateEmail();
|
|
|
}
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ String code = yhMailService.getGptCode(account);
|
|
|
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) {
|
|
|
-
|
|
|
- }
|
|
|
+ re.putOpt("code", code);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
|
}
|
|
|
|