From 1ed1752f678f769e43e9faa34809701850c7f727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 30 Mar 2023 19:14:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E6=9C=89=E6=95=88=E6=9C=9F=20=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=AE=A1=E7=90=86=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/web/controller/CaptchaController.java | 12 +++++++----- .../com/ruoyi/common/core/constant/Constants.java | 5 ----- script/sql/oracle/oracle_ry_vue_5.X.sql | 2 ++ script/sql/postgres/postgres_ry_vue_5.X.sql | 10 ++++++---- script/sql/ry_vue_5.X.sql | 13 +++++++------ script/sql/sqlserver/sqlserver_ry_vue_5.X.sql | 4 ++++ 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/CaptchaController.java index f3940c63..fec91b9b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/CaptchaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/CaptchaController.java @@ -6,7 +6,6 @@ import cn.hutool.captcha.generator.CodeGenerator; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.RandomUtil; -import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.GlobalConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.SpringUtils; @@ -64,7 +63,8 @@ public class CaptchaController { } String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber; String code = RandomUtil.randomNumbers(4); - RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); + Integer captchaExpired = Convert.toInt(configService.selectConfigByKey("sys.account.captchaExpired")); + RedisUtils.setCacheObject(key, code, Duration.ofMinutes(captchaExpired)); // 验证码模板id 自行处理 (查数据库或写死均可) String templateId = configService.selectConfigByKey("sys.account.templateId"); Map map = new HashMap<>(1); @@ -90,9 +90,10 @@ public class CaptchaController { } String key = GlobalConstants.CAPTCHA_CODE_KEY + email; String code = RandomUtil.randomNumbers(4); - RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); + Integer captchaExpired = Convert.toInt(configService.selectConfigByKey("sys.account.captchaExpired")); + RedisUtils.setCacheObject(key, code, Duration.ofMinutes(captchaExpired)); try { - MailUtils.sendText(email, "登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。"); + MailUtils.sendText(email, "登录验证码", "您本次验证码为:%s,有效性为%d分钟,请尽快填写。".formatted(code, captchaExpired)); } catch (Exception e) { log.error("验证码短信发送异常 => {}", e.getMessage()); return R.fail(e.getMessage()); @@ -128,7 +129,8 @@ public class CaptchaController { Expression exp = parser.parseExpression(StringUtils.remove(code, "=")); code = exp.getValue(String.class); } - RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); + Integer captchaExpired = Convert.toInt(configService.selectConfigByKey("sys.account.captchaExpired")); + RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(captchaExpired)); captchaVo.setUuid(uuid); captchaVo.setImg(captcha.getImageBase64()); return R.ok(captchaVo); diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java index 9553d174..203be87f 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java @@ -62,11 +62,6 @@ public interface Constants { */ String LOGIN_FAIL = "Error"; - /** - * 验证码有效期(分钟) - */ - Integer CAPTCHA_EXPIRATION = 2; - /** * 令牌 */ diff --git a/script/sql/oracle/oracle_ry_vue_5.X.sql b/script/sql/oracle/oracle_ry_vue_5.X.sql index 4c7c56a6..2c3ceb20 100644 --- a/script/sql/oracle/oracle_ry_vue_5.X.sql +++ b/script/sql/oracle/oracle_ry_vue_5.X.sql @@ -827,11 +827,13 @@ comment on column sys_config.remark is '备注'; insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate, null, null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' ); insert into sys_config values(2, '000000', '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 103, 1, sysdate, null, null, '初始化密码 123456' ); insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate, null, null, '深色主题theme-dark,浅色主题theme-light' ); +insert into sys_config values(4, '000000', '用户配置-验证码有效期', 'sys.account.captchaExpired', '2', 'Y', 103, 1, sysdate, null, NULL, '验证码有效期(分钟)'); insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate, null, null, '是否开启注册用户功能(true开启,false关闭)'); insert into sys_config values(6, '000000', '用户配置-密码最大错误次数', 'sys.user.maxRetryCount', '5', 'Y', 103, 1, sysdate, null, null, '密码最大错误次数'); insert into sys_config values(7, '000000', '用户配置-密码锁定时间', 'sys.user.lockTime', '10', 'Y', 103, 1, sysdate, null, null, '密码锁定时间(分钟)'); insert into sys_config values(8, '000000', '账号自助-短信开关', 'sys.account.smsEnabled', 'false', 'Y', 103, 1, sysdate, null, null, '是否开启短信功能(true开启,false关闭)'); insert into sys_config values(9, '000000', '账号自助-验证码模板id', 'sys.account.templateId', '', 'Y', 103, 1, sysdate, null, null, '验证码模板id'); +insert into sys_config values(10, '000000', '账号自助-邮件开关', 'sys.account.emailEnabled', 'false', 'Y', 103, 1, sysdate, null, NULL, '是否开启邮件功能(true开启,false关闭)'); insert into sys_config values(11, '000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate, null, null, 'true:开启, false:关闭'); diff --git a/script/sql/postgres/postgres_ry_vue_5.X.sql b/script/sql/postgres/postgres_ry_vue_5.X.sql index 5e394a0d..037b1b2f 100644 --- a/script/sql/postgres/postgres_ry_vue_5.X.sql +++ b/script/sql/postgres/postgres_ry_vue_5.X.sql @@ -848,11 +848,13 @@ comment on column sys_config.remark is '备注'; insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, now(), null, null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' ); insert into sys_config values(2, '000000', '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 103, 1, now(), null, null, '初始化密码 123456' ); insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, now(), null, null, '深色主题theme-dark,浅色主题theme-light' ); +insert into sys_config values(4, '000000', '用户配置-验证码有效期', 'sys.account.captchaExpired', '2', 'Y', 103, 1, now(), null, NULL, '验证码有效期(分钟)'); insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, now(), null, null, '是否开启注册用户功能(true开启,false关闭)'); -insert into sys_config values(6, '000000', '用户配置-密码最大错误次数', 'sys.user.maxRetryCount', '5', 'Y', 103, 1,now(), null, null, '密码最大错误次数'); -insert into sys_config values(7, '000000', '用户配置-密码锁定时间', 'sys.user.lockTime', '10', 'Y', 103, 1, now(), null, null, '密码锁定时间(分钟)'); -insert into sys_config values(8, '000000', '账号自助-短信开关', 'sys.account.smsEnabled', 'false', 'Y', 103, 1, now(), null, null, '是否开启短信功能(true开启,false关闭)'); -insert into sys_config values(9, '000000', '账号自助-验证码模板id', 'sys.account.templateId', '', 'Y', 103, 1, now(), null, null, '验证码模板id'); +insert into sys_config values(6, '000000', '用户配置-密码最大错误次数', 'sys.user.maxRetryCount', '5', 'Y', 103, 1,now(), null, null, '密码最大错误次数'); +insert into sys_config values(7, '000000', '用户配置-密码锁定时间', 'sys.user.lockTime', '10', 'Y', 103, 1, now(), null, null, '密码锁定时间(分钟)'); +insert into sys_config values(8, '000000', '账号自助-短信开关', 'sys.account.smsEnabled', 'false', 'Y', 103, 1, now(), null, null, '是否开启短信功能(true开启,false关闭)'); +insert into sys_config values(9, '000000', '账号自助-验证码模板id', 'sys.account.templateId', '', 'Y', 103, 1, now(), null, null, '验证码模板id'); +insert into sys_config values(10, '000000', '账号自助-邮件开关', 'sys.account.emailEnabled', 'false', 'Y', 103, 1, now(), null, NULL, '是否开启邮件功能(true开启,false关闭)'); insert into sys_config values(11, '000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, now(), null, null, 'true:开启, false:关闭'); diff --git a/script/sql/ry_vue_5.X.sql b/script/sql/ry_vue_5.X.sql index 41290d29..ca4fe113 100644 --- a/script/sql/ry_vue_5.X.sql +++ b/script/sql/ry_vue_5.X.sql @@ -628,13 +628,14 @@ create table sys_config ( insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate(), null, NULL, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow'); insert into sys_config values(2, '000000', '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 103, 1, sysdate(), null, NULL, '初始化密码 123456'); insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate(), null, NULL, '深色主题theme-dark,浅色主题theme-light'); -insert into sys_config values(4, '000000', '账号自助-验证码开关', 'sys.account.captchaEnabled', 'true', 'Y', 103, 1, sysdate(), null, NULL, '是否开启验证码功能(true开启,false关闭)'); -insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate(), null, NULL, '是否开启注册用户功能(true开启,false关闭)'); +insert into sys_config values(4, '000000', '用户配置-验证码有效期', 'sys.account.captchaExpired', '2', 'Y', 103, 1, sysdate(), null, NULL, '验证码有效期(分钟)'); +insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate(), null, NULL, '是否开启注册用户功能(true开启,false关闭)'); insert into sys_config values(6, '000000', '用户配置-密码最大错误次数', 'sys.user.maxRetryCount', '5', 'Y', 103, 1, sysdate(), null, NULL, '密码最大错误次数'); -insert into sys_config values(7, '000000', '用户配置-密码锁定时间', 'sys.user.lockTime', '10', 'Y', 103, 1, sysdate(), null, NULL, '密码锁定时间(分钟)'); -insert into sys_config values(8, '000000', '账号自助-短信开关', 'sys.account.smsEnabled', 'false', 'Y', 103, 1, sysdate(), null, NULL, '是否开启短信功能(true开启,false关闭)'); -insert into sys_config values(9, '000000', '账号自助-验证码模板id', 'sys.account.templateId', '', 'Y', 103, 1, sysdate(), null, NULL, '验证码模板id'); -insert into sys_config values(11,'000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate(), null, NULL, 'true:开启, false:关闭'); +insert into sys_config values(7, '000000', '用户配置-密码锁定时间', 'sys.user.lockTime', '10', 'Y', 103, 1, sysdate(), null, NULL, '密码锁定时间(分钟)'); +insert into sys_config values(8, '000000', '账号自助-短信开关', 'sys.account.smsEnabled', 'false', 'Y', 103, 1, sysdate(), null, NULL, '是否开启短信功能(true开启,false关闭)'); +insert into sys_config values(9, '000000', '账号自助-短信验证码模板id', 'sys.account.templateId', '', 'Y', 103, 1, sysdate(), null, NULL, '验证码模板id'); +insert into sys_config values(10, '000000', '账号自助-邮件开关', 'sys.account.emailEnabled', 'false', 'Y', 103, 1, sysdate(), null, NULL, '是否开启邮件功能(true开启,false关闭)'); +insert into sys_config values(11,'000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate(), null, NULL, 'true:开启, false:关闭'); -- ---------------------------- -- 14、系统访问记录 diff --git a/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql b/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql index 53a8c079..38e2b2fc 100644 --- a/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql +++ b/script/sql/sqlserver/sqlserver_ry_vue_5.X.sql @@ -694,6 +694,8 @@ INSERT sys_config VALUES (2, N'000000', N'用户管理-账号初始密码', N'sy GO INSERT sys_config VALUES (3, N'000000', N'主框架页-侧边栏主题', N'sys.index.sideTheme', N'theme-dark', N'Y', 103, 1, getdate(), NULL, NULL, N'深色主题theme-dark,浅色主题theme-light') GO +INSERT sys_config VALUES (4, N'000000', N'用户配置-验证码有效期', N'sys.account.captchaExpired', N'2', N'Y', 103, 1, sysdate(), null, NULL, N'验证码有效期(分钟)'); +GO INSERT sys_config VALUES (5, N'000000', N'账号自助-是否开启用户注册功能', N'sys.account.registerUser', N'false', N'Y', 103, 1, getdate(), NULL, NULL, N'是否开启注册用户功能(true开启,false关闭)') GO INSERT sys_config VALUES (6, N'000000', N'用户配置-密码最大错误次数', N'sys.user.maxRetryCount', N'5', N'Y', 103, 1, getdate(), NULL, NULL, N'密码最大错误次数') @@ -704,6 +706,8 @@ INSERT sys_config VALUES (8, N'000000', N'账号自助-短信开关', N'sys.acco GO INSERT sys_config VALUES (9, N'000000', N'账号自助-验证码模板id', N'sys.account.templateId', N'', N'Y', 103, 1, getdate(), NULL, NULL, N'验证码模板id') GO +INSERT sys_config VALUES (10, N'000000', N'账号自助-邮件开关', N'sys.account.emailEnabled', N'false', N'Y', 103, 1, getdate(), NULL, NULL, N'是否开启邮件功能(true开启,false关闭)') +GO INSERT sys_config VALUES (11, N'000000', N'OSS预览列表资源开关', N'sys.oss.previewListResource', N'true', N'Y', 103, 1, getdate(), NULL, NULL, N'true:开启, false:关闭'); GO