|
@@ -3,10 +3,15 @@ package com.cyksj.web.controller.manage.group;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
|
|
+import com.cyksj.common.util.GoogleGenerator;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
@@ -34,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -220,4 +226,40 @@ public class CmsGroupController {
|
|
|
.eq(Account::getId, accountId));
|
|
.eq(Account::getId, accountId));
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("下架成功");
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("下架成功");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取双重验证码
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/verifyCode")
|
|
|
|
|
+ public Result<String> getVerifyCode(String apiSecret) {
|
|
|
|
|
+ if (StrUtil.isBlank(apiSecret)) throw BusinessRuntimeException.getInstance("双重密钥为空");
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
|
+ int second = now.second();
|
|
|
|
|
+ if (second < 30 && 30 - second < 5) {
|
|
|
|
|
+ ThreadUtil.sleep(30 - second + 1, TimeUnit.SECONDS);
|
|
|
|
|
+ } else if (second > 30 && 60 - second < 5) {
|
|
|
|
|
+ ThreadUtil.sleep(60 - second + 1, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
+ try {
|
|
|
|
|
+ long code = GoogleGenerator.getCode(apiSecret, now.getTime());
|
|
|
|
|
+ sb.append(code);
|
|
|
|
|
+ while (sb.length() < 6) {
|
|
|
|
|
+ sb.insert(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("双重验证密钥错误,请生成新的验证密钥");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject re = new JSONObject();
|
|
|
|
|
+ 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);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|