增加验证码的开关的功能

This commit is contained in:
jishenghua
2025-09-21 16:31:03 +08:00
parent d3643c2a99
commit ca89353667
4 changed files with 49 additions and 18 deletions

View File

@@ -685,6 +685,7 @@ INSERT INTO `jsh_platform_config` VALUES ('18', 'bill_excel_url', '单据Excel
INSERT INTO `jsh_platform_config` VALUES ('19', 'email_from', '邮件发送端-发件人', ''); INSERT INTO `jsh_platform_config` VALUES ('19', 'email_from', '邮件发送端-发件人', '');
INSERT INTO `jsh_platform_config` VALUES ('20', 'email_auth_code', '邮件发送端-授权码', ''); INSERT INTO `jsh_platform_config` VALUES ('20', 'email_auth_code', '邮件发送端-授权码', '');
INSERT INTO `jsh_platform_config` VALUES ('21', 'email_smtp_host', '邮件发送端-SMTP服务器', ''); INSERT INTO `jsh_platform_config` VALUES ('21', 'email_smtp_host', '邮件发送端-SMTP服务器', '');
INSERT INTO `jsh_platform_config` VALUES ('22', 'checkcode_flag', '验证码启用标记', '1');
-- ---------------------------- -- ----------------------------
-- Table structure for jsh_role -- Table structure for jsh_role

View File

@@ -1698,4 +1698,11 @@ alter table jsh_material change other_field3 other_field3 varchar(500) DEFAULT N
-- -------------------------------------------------------- -- --------------------------------------------------------
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_from', '邮件发送端-发件人', ''); insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_from', '邮件发送端-发件人', '');
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_auth_code', '邮件发送端-授权码', ''); insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_auth_code', '邮件发送端-授权码', '');
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_smtp_host', '邮件发送端-SMTP服务器', ''); insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_smtp_host', '邮件发送端-SMTP服务器', '');
-- --------------------------------------------------------
-- 时间 2025年9月21日
-- by jishenghua
-- 给平台表增加验证码启用标记
-- --------------------------------------------------------
insert into jsh_platform_config(platform_key, platform_key_info, platform_value) values ('checkcode_flag', '验证码启用标记', '1');

View File

@@ -151,6 +151,26 @@ public class PlatformConfigController extends BaseController {
return res; return res;
} }
/**
* 获取是否开启验证码
* @param request
* @return
*/
@GetMapping(value = "/getPlatform/checkcodeFlag")
@ApiOperation(value = "获取是否开启验证码")
public String getPlatformCheckcodeFlag(HttpServletRequest request)throws Exception {
String res;
try {
String platformKey = "checkcode_flag";
PlatformConfig platformConfig = platformConfigService.getInfoByKey(platformKey);
res = platformConfig.getPlatformValue();
} catch(Exception e){
logger.error(e.getMessage(), e);
res = "#";
}
return res;
}
/** /**
* 根据platformKey更新platformValue * 根据platformKey更新platformValue
* @param object * @param object

View File

@@ -288,24 +288,27 @@ public class UserService {
* @param uuid 唯一标识 * @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */
public void validateCaptcha(String code, String uuid) { public void validateCaptcha(String code, String uuid) throws Exception {
if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) { PlatformConfig platformConfig = platformConfigService.getInfoByKey("checkcode_flag");
code = code.trim(); if(platformConfig!=null && "1".equals(platformConfig.getPlatformValue())) {
uuid = uuid.trim(); if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) {
String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid; code = code.trim();
String captcha = redisService.getCacheObject(verifyKey); uuid = uuid.trim();
redisService.deleteObject(verifyKey); String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid;
if (captcha == null) { String captcha = redisService.getCacheObject(verifyKey);
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG); redisService.deleteObject(verifyKey);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG); if (captcha == null) {
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
}
if (!code.equalsIgnoreCase(captcha)) {
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
}
} else {
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
} }
if (!code.equalsIgnoreCase(captcha)) {
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
}
} else {
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
} }
} }