新增:重置短信验证码接口
This commit is contained in:
@@ -4,17 +4,24 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.AccessKey;
|
||||
import com.gxwebsoft.common.system.param.AccessKeyParam;
|
||||
import com.gxwebsoft.common.system.service.AccessKeyService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.WebsiteConstants.CACHE_KEY_VERIFICATION_CODE_BY_DEV_SMS;
|
||||
|
||||
/**
|
||||
* 访问凭证管理控制器
|
||||
@@ -30,6 +37,8 @@ public class AccessKeyController extends BaseController {
|
||||
private AccessKeyService accessKeyService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@@ -41,13 +50,13 @@ public class AccessKeyController extends BaseController {
|
||||
if (param.getCode() != null) {
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(param.getPhone(), String.class);
|
||||
if (StrUtil.equals(code,param.getCode()) || "128880".equals(param.getCode())) {
|
||||
if (StrUtil.equals(code, param.getCode()) || "128880".equals(param.getCode())) {
|
||||
return success(accessKeyPageResult);
|
||||
}
|
||||
return fail("短信验证码不正确",null);
|
||||
return fail("短信验证码不正确", null);
|
||||
}
|
||||
// 默认不给查看AccessSecret
|
||||
accessKeyPageResult.getList().forEach( d -> {
|
||||
accessKeyPageResult.getList().forEach(d -> {
|
||||
d.setAccessSecret(null);
|
||||
});
|
||||
return success(accessKeyPageResult);
|
||||
@@ -147,4 +156,17 @@ public class AccessKeyController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:resetSMSCode')")
|
||||
@OperationLog
|
||||
@ApiOperation("重置短信验证码")
|
||||
@PostMapping("/resetSMSCode")
|
||||
public ApiResult<?> resetSMSCode() {
|
||||
// 生成短信验证码
|
||||
Random randObj = new Random();
|
||||
String code = Integer.toString(100000 + randObj.nextInt(900000));
|
||||
redisUtil.set(CACHE_KEY_VERIFICATION_CODE_BY_DEV_SMS, code, 5L, TimeUnit.MINUTES);
|
||||
return success("新验证码:".concat(code));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user