验证码校验接口
This commit is contained in:
parent
946a7a317c
commit
ce382d9c2c
|
@ -0,0 +1,39 @@
|
|||
package com.kening.vordm.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.common.cache.CacheNames;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wanghongqing
|
||||
* @date 2023/3/31 11:10
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/captcha")
|
||||
@RequiredArgsConstructor
|
||||
@Api(value = "验证码校验接口", tags = "验证码校验")
|
||||
public class CaptchaController extends BladeController {
|
||||
|
||||
private final BladeRedis bladeRedis;
|
||||
|
||||
@PostMapping("/validate")
|
||||
@ApiOperation(value = "验证码校验", notes = "传入需要校验的验证码以及缓存Key")
|
||||
public R<String> validDefaultTime(@RequestParam String code, @RequestParam String key) {
|
||||
// 获取验证码
|
||||
String redisCode = bladeRedis.get(CacheNames.CAPTCHA_KEY + key);
|
||||
// 判断验证码
|
||||
if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) {
|
||||
return R.fail(1404, "Verification code error");
|
||||
}
|
||||
return R.success("OK");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue