mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-15 02:57:10 +08:00
feat(system/smsConfig): 短信配置新增设为默认功能
This commit is contained in:
@@ -47,7 +47,9 @@ import top.continew.admin.common.config.properties.CaptchaProperties;
|
||||
import top.continew.admin.common.constant.CacheConstants;
|
||||
import top.continew.admin.common.constant.SysConstants;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.model.entity.SmsConfigDO;
|
||||
import top.continew.admin.system.service.OptionService;
|
||||
import top.continew.admin.system.service.SmsConfigService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.captcha.graphic.core.GraphicCaptchaService;
|
||||
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||
@@ -87,6 +89,7 @@ public class CaptchaController {
|
||||
private final CaptchaService behaviorCaptchaService;
|
||||
private final GraphicCaptchaService graphicCaptchaService;
|
||||
private final OptionService optionService;
|
||||
private final SmsConfigService smsConfigService;
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "获取行为验证码", description = "获取行为验证码(Base64编码)")
|
||||
@@ -201,14 +204,17 @@ public class CaptchaController {
|
||||
CaptchaProperties.CaptchaSms captchaSms = captchaProperties.getSms();
|
||||
// 生成验证码
|
||||
String captcha = RandomUtil.randomNumbers(captchaSms.getLength());
|
||||
// 发送验证码
|
||||
Long expirationInMinutes = captchaSms.getExpirationInMinutes();
|
||||
SmsBlend smsBlend = SmsFactory.getBySupplier(captchaSms.getSupplier());
|
||||
// 获取短信配置
|
||||
SmsConfigDO smsConfig = smsConfigService.getDefaultConfig();
|
||||
SmsBlend smsBlend = smsConfig != null
|
||||
? SmsFactory.getBySupplier(smsConfig.getSupplier())
|
||||
: SmsFactory.getSmsBlend();
|
||||
Map<String, String> messageMap = MapUtil.newHashMap(2, true);
|
||||
messageMap.put(captchaSms.getCodeKey(), captcha);
|
||||
messageMap.put(captchaSms.getTimeKey(), String.valueOf(expirationInMinutes));
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phone, captchaSms
|
||||
.getTemplateId(), (LinkedHashMap<String, String>)messageMap);
|
||||
// 发送验证码
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phone, (LinkedHashMap<String, String>)messageMap);
|
||||
CheckUtils.throwIf(!smsResponse.isSuccess(), "验证码发送失败");
|
||||
// 保存验证码
|
||||
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + phone;
|
||||
|
@@ -16,8 +16,14 @@
|
||||
|
||||
package top.continew.admin.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.continew.admin.common.controller.BaseController;
|
||||
import top.continew.admin.system.model.query.SmsConfigQuery;
|
||||
@@ -38,4 +44,13 @@ import top.continew.starter.extension.crud.enums.Api;
|
||||
@Validated
|
||||
@RestController
|
||||
@CrudRequestMapping(value = "/system/smsConfig", api = {Api.PAGE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE})
|
||||
public class SmsConfigController extends BaseController<SmsConfigService, SmsConfigResp, SmsConfigResp, SmsConfigQuery, SmsConfigReq> {}
|
||||
public class SmsConfigController extends BaseController<SmsConfigService, SmsConfigResp, SmsConfigResp, SmsConfigQuery, SmsConfigReq> {
|
||||
|
||||
@Operation(summary = "设为默认配置", description = "设为默认配置")
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@SaCheckPermission("system:smsConfig:setDefault")
|
||||
@PutMapping({"/{id}/default"})
|
||||
public void setDefault(@PathVariable("id") Long id) {
|
||||
baseService.setDefaultConfig(id);
|
||||
}
|
||||
}
|
@@ -60,6 +60,6 @@ public class StorageController extends BaseController<StorageService, StorageRes
|
||||
@SaCheckPermission("system:storage:setDefault")
|
||||
@PutMapping({"/{id}/default"})
|
||||
public void setDefault(@PathVariable("id") Long id) {
|
||||
baseService.setDefault(id);
|
||||
baseService.setDefaultStorage(id);
|
||||
}
|
||||
}
|
@@ -130,8 +130,6 @@ captcha:
|
||||
length: 6
|
||||
# 过期时间
|
||||
expirationInMinutes: 5
|
||||
# 模板 ID
|
||||
templateId: 1
|
||||
|
||||
--- ### 日志配置
|
||||
## API 请求/响应日志配置
|
||||
|
@@ -132,8 +132,6 @@ captcha:
|
||||
length: 6
|
||||
# 过期时间
|
||||
expirationInMinutes: 5
|
||||
# 模板 ID
|
||||
templateId: 1
|
||||
|
||||
--- ### 日志配置
|
||||
## API 请求/响应日志配置
|
||||
|
@@ -93,6 +93,7 @@ VALUES
|
||||
(1214, '修改', 1210, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:smsConfig:update', 4, 1, 1, NOW()),
|
||||
(1215, '删除', 1210, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:smsConfig:delete', 5, 1, 1, NOW()),
|
||||
(1216, '导出', 1210, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:smsConfig:export', 6, 1, 1, NOW()),
|
||||
(1217, '设为默认配置', 1210, 3, NULL, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:smsConfig:setDefault', 7, 1, 1, NOW()),
|
||||
(1230, '存储配置', 1150, 2, '/system/config?tab=storage', 'SystemStorage', 'system/config/storage/index', NULL, 'storage', b'0', b'0', b'1', NULL, 6, 1, 1, NOW()),
|
||||
(1231, '列表', 1230, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:list', 1, 1, 1, NOW()),
|
||||
(1232, '详情', 1230, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:get', 2, 1, 1, NOW()),
|
||||
|
@@ -335,6 +335,7 @@ CREATE TABLE IF NOT EXISTS `sys_sms_config` (
|
||||
`max_retries` int DEFAULT NULL COMMENT '重试次数',
|
||||
`maximum` int DEFAULT NULL COMMENT '发送上限',
|
||||
`supplier_config` text DEFAULT NULL COMMENT '各个厂商独立配置',
|
||||
`is_default` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否为默认配置',
|
||||
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(1:启用;2:禁用)',
|
||||
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
|
@@ -93,6 +93,7 @@ VALUES
|
||||
(1214, '修改', 1210, 3, NULL, NULL, NULL, NULL, NULL, false, false, false, 'system:smsConfig:update', 4, 1, 1, NOW()),
|
||||
(1215, '删除', 1210, 3, NULL, NULL, NULL, NULL, NULL, false, false, false, 'system:smsConfig:delete', 5, 1, 1, NOW()),
|
||||
(1216, '导出', 1210, 3, NULL, NULL, NULL, NULL, NULL, false, false, false, 'system:smsConfig:export', 6, 1, 1, NOW()),
|
||||
(1217, '设为默认配置', 1210, 3, NULL, NULL, NULL, NULL, NULL, false, false, false, 'system:smsConfig:setDefault', 7, 1, 1, NOW()),
|
||||
(1230, '存储配置', 1150, 2, '/system/config?tab=storage', 'SystemStorage', 'system/config/storage/index', NULL, 'storage', false, false, true, NULL, 6, 1, 1, NOW()),
|
||||
(1231, '列表', 1230, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:list', 1, 1, 1, NOW()),
|
||||
(1232, '详情', 1230, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:get', 2, 1, 1, NOW()),
|
||||
|
@@ -553,6 +553,7 @@ CREATE TABLE IF NOT EXISTS "sys_sms_config" (
|
||||
"max_retries" int4 DEFAULT NULL,
|
||||
"maximum" int4 DEFAULT NULL,
|
||||
"supplier_config" text DEFAULT NULL ,
|
||||
"is_default" bool NOT NULL DEFAULT false,
|
||||
"status" int2 NOT NULL DEFAULT 1,
|
||||
"create_user" int8 NOT NULL,
|
||||
"create_time" timestamp NOT NULL,
|
||||
@@ -574,6 +575,7 @@ COMMENT ON COLUMN "sys_sms_config"."retry_interval" IS '重试间隔(单位
|
||||
COMMENT ON COLUMN "sys_sms_config"."max_retries" IS '重试次数';
|
||||
COMMENT ON COLUMN "sys_sms_config"."maximum" IS '发送上限';
|
||||
COMMENT ON COLUMN "sys_sms_config"."supplier_config" IS '各个厂商独立配置';
|
||||
COMMENT ON COLUMN "sys_sms_config"."is_default" IS '是否为默认配置';
|
||||
COMMENT ON COLUMN "sys_sms_config"."status" IS '状态(1:启用;2:禁用)';
|
||||
COMMENT ON COLUMN "sys_sms_config"."create_user" IS '创建人';
|
||||
COMMENT ON COLUMN "sys_sms_config"."create_time" IS '创建时间';
|
||||
|
Reference in New Issue
Block a user