优化短信模块的代码

This commit is contained in:
YunaiV 2022-04-11 01:21:33 +08:00
parent e33b2f0dd3
commit 076c7a4e3e
18 changed files with 41 additions and 40 deletions

View File

@ -3716,7 +3716,7 @@ INSERT INTO `system_menu` VALUES (1128, '支付应用信息创建', 'pay:app:cre
INSERT INTO `system_menu` VALUES (1129, '支付应用信息更新', 'pay:app:update', 3, 3, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0'); INSERT INTO `system_menu` VALUES (1129, '支付应用信息更新', 'pay:app:update', 3, 3, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0');
INSERT INTO `system_menu` VALUES (1130, '支付应用信息删除', 'pay:app:delete', 3, 4, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0'); INSERT INTO `system_menu` VALUES (1130, '支付应用信息删除', 'pay:app:delete', 3, 4, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0');
INSERT INTO `system_menu` VALUES (1131, '支付应用信息导出', 'pay:app:export', 3, 5, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0'); INSERT INTO `system_menu` VALUES (1131, '支付应用信息导出', 'pay:app:export', 3, 5, 1126, '', '', '', 0, '', '2021-11-10 01:13:31', '', '2021-11-10 01:13:31', b'0');
INSERT INTO `system_menu` VALUES (1132, '钥解析', 'pay:channel:parsing', 3, 6, 1129, '', '', '', 0, '1', '2021-11-08 15:15:47', '1', '2021-11-08 15:15:47', b'0'); INSERT INTO `system_menu` VALUES (1132, '钥解析', 'pay:channel:parsing', 3, 6, 1129, '', '', '', 0, '1', '2021-11-08 15:15:47', '1', '2021-11-08 15:15:47', b'0');
INSERT INTO `system_menu` VALUES (1133, '支付商户信息查询', 'pay:merchant:query', 3, 1, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0'); INSERT INTO `system_menu` VALUES (1133, '支付商户信息查询', 'pay:merchant:query', 3, 1, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0');
INSERT INTO `system_menu` VALUES (1134, '支付商户信息创建', 'pay:merchant:create', 3, 2, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0'); INSERT INTO `system_menu` VALUES (1134, '支付商户信息创建', 'pay:merchant:create', 3, 2, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0');
INSERT INTO `system_menu` VALUES (1135, '支付商户信息更新', 'pay:merchant:update', 3, 3, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0'); INSERT INTO `system_menu` VALUES (1135, '支付商户信息更新', 'pay:merchant:update', 3, 3, 1132, '', '', '', 0, '', '2021-11-10 01:13:41', '', '2021-11-10 01:13:41', b'0');
@ -3734,7 +3734,7 @@ INSERT INTO `system_menu` VALUES (1146, '支付应用信息创建', 'pay:app:cre
INSERT INTO `system_menu` VALUES (1147, '支付应用信息更新', 'pay:app:update', 3, 3, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:48', b'1'); INSERT INTO `system_menu` VALUES (1147, '支付应用信息更新', 'pay:app:update', 3, 3, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:48', b'1');
INSERT INTO `system_menu` VALUES (1148, '支付应用信息删除', 'pay:app:delete', 3, 4, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:46', b'1'); INSERT INTO `system_menu` VALUES (1148, '支付应用信息删除', 'pay:app:delete', 3, 4, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:46', b'1');
INSERT INTO `system_menu` VALUES (1149, '支付应用信息导出', 'pay:app:export', 3, 5, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:43', b'1'); INSERT INTO `system_menu` VALUES (1149, '支付应用信息导出', 'pay:app:export', 3, 5, 1144, '', '', '', 0, '', '2021-12-25 08:26:31', '', '2021-12-25 08:47:43', b'1');
INSERT INTO `system_menu` VALUES (1150, '钥解析', 'pay:channel:parsing', 3, 6, 1129, '', '', '', 0, '1', '2021-11-08 15:15:47', '1', '2021-11-08 15:15:47', b'0'); INSERT INTO `system_menu` VALUES (1150, '钥解析', 'pay:channel:parsing', 3, 6, 1129, '', '', '', 0, '1', '2021-11-08 15:15:47', '1', '2021-11-08 15:15:47', b'0');
INSERT INTO `system_menu` VALUES (1156, '支付订单查询', 'pay:order:query', 3, 1, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:18', b'1'); INSERT INTO `system_menu` VALUES (1156, '支付订单查询', 'pay:order:query', 3, 1, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:18', b'1');
INSERT INTO `system_menu` VALUES (1157, '支付订单创建', 'pay:order:create', 3, 2, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:39', b'1'); INSERT INTO `system_menu` VALUES (1157, '支付订单创建', 'pay:order:create', 3, 2, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:39', b'1');
INSERT INTO `system_menu` VALUES (1158, '支付订单更新', 'pay:order:update', 3, 3, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:50', b'1'); INSERT INTO `system_menu` VALUES (1158, '支付订单更新', 'pay:order:update', 3, 3, 1155, '', '', '', 0, '', '2021-12-25 08:29:01', '', '2022-03-23 16:45:50', b'1');
@ -6039,7 +6039,7 @@ CREATE TABLE `system_sms_channel` (
`status` tinyint NOT NULL COMMENT '开启状态', `status` tinyint NOT NULL COMMENT '开启状态',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
`api_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '短信 API 的账号', `api_key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '短信 API 的账号',
`api_secret` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '短信 API ', `api_secret` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '短信 API ',
`callback_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '短信发送回调 URL', `callback_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '短信发送回调 URL',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

View File

@ -82,9 +82,9 @@ public class WXPayClientConfig implements PayClientConfig {
@NotBlank(message = "apiclient_cert 不能为空", groups = V3.class) @NotBlank(message = "apiclient_cert 不能为空", groups = V3.class)
private String privateCertContent; private String privateCertContent;
/** /**
* apiV3 钥值 * apiV3 钥值
*/ */
@NotBlank(message = "apiV3 钥值 不能为空", groups = V3.class) @NotBlank(message = "apiV3 钥值 不能为空", groups = V3.class)
private String apiV3Key; private String apiV3Key;
/** /**

View File

@ -11,7 +11,7 @@ import java.util.List;
* 短信客户端用于对接各短信平台的 SDK实现短信发送等功能 * 短信客户端用于对接各短信平台的 SDK实现短信发送等功能
* *
* @author zzf * @author zzf
* @date 2021/1/25 14:14 * @since 2021/1/25 14:14
*/ */
public interface SmsClient { public interface SmsClient {

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
* 短信客户端的工厂接口 * 短信客户端的工厂接口
* *
* @author zzf * @author zzf
* @date 2021/1/28 14:01 * @since 2021/1/28 14:01
*/ */
public interface SmsClientFactory { public interface SmsClientFactory {

View File

@ -16,7 +16,7 @@ import java.util.List;
* 短信客户端的抽象类提供模板方法减少子类的冗余代码 * 短信客户端的抽象类提供模板方法减少子类的冗余代码
* *
* @author zzf * @author zzf
* @date 2021/2/1 9:28 * @since 2021/2/1 9:28
*/ */
@Slf4j @Slf4j
public abstract class AbstractSmsClient implements SmsClient { public abstract class AbstractSmsClient implements SmsClient {

View File

@ -41,7 +41,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DE
* 阿里短信客户端的实现类 * 阿里短信客户端的实现类
* *
* @author zzf * @author zzf
* @date 2021/1/25 14:17 * @since 2021/1/25 14:17
*/ */
@Slf4j @Slf4j
public class AliyunSmsClient extends AbstractSmsClient { public class AliyunSmsClient extends AbstractSmsClient {

View File

@ -1,7 +1,8 @@
package cn.iocoder.yudao.framework.sms.core.property; package cn.iocoder.yudao.framework.sms.core.client.impl.tencent;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
import lombok.Data; import lombok.Data;
/** /**

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.sms.core.client.impl.tencent; package cn.iocoder.yudao.framework.sms.core.client.impl.tencent;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.core.KeyValue;
@ -14,7 +13,6 @@ import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO;
import cn.iocoder.yudao.framework.sms.core.client.impl.AbstractSmsClient; import cn.iocoder.yudao.framework.sms.core.client.impl.AbstractSmsClient;
import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
import cn.iocoder.yudao.framework.sms.core.property.TencentSmsChannelProperties;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;

View File

@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DE
* 云片短信客户端的实现类 * 云片短信客户端的实现类
* *
* @author zzf * @author zzf
* @date 9:48 2021/3/5 * @since 9:48 2021/3/5
*/ */
@Slf4j @Slf4j
public class YunpianSmsClient extends AbstractSmsClient { public class YunpianSmsClient extends AbstractSmsClient {

View File

@ -8,7 +8,7 @@ import lombok.Getter;
* 短信渠道枚举 * 短信渠道枚举
* *
* @author zzf * @author zzf
* @date 2021/1/25 10:56 * @since 2021/1/25 10:56
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor

View File

@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
* 短信渠道配置类 * 短信渠道配置类
* *
* @author zzf * @author zzf
* @date 2021/1/25 17:01 * @since 2021/1/25 17:01
*/ */
@Data @Data
@Validated @Validated
@ -40,9 +40,9 @@ public class SmsChannelProperties {
@NotEmpty(message = "短信 API 的账号不能为空") @NotEmpty(message = "短信 API 的账号不能为空")
private String apiKey; private String apiKey;
/** /**
* 短信 API * 短信 API
*/ */
@NotEmpty(message = "短信 API 的钥不能为空") @NotEmpty(message = "短信 API 的钥不能为空")
private String apiSecret; private String apiSecret;
/** /**
* 短信发送回调 URL * 短信发送回调 URL

View File

@ -37,10 +37,10 @@ public class SecurityProperties {
@NotNull(message = "mock 模式的开关不能为空") @NotNull(message = "mock 模式的开关不能为空")
private Boolean mockEnable; private Boolean mockEnable;
/** /**
* mock 模式的 * mock 模式的
* 一定要配置保证安全性 * 一定要配置保证安全性
*/ */
@NotEmpty(message = "mock 模式的钥不能为空") // 这里设置了一个默认值因为实际上只有 mockEnable true 时才需要配置 @NotEmpty(message = "mock 模式的钥不能为空") // 这里设置了一个默认值因为实际上只有 mockEnable true 时才需要配置
private String mockSecret = "yudaoyuanma"; private String mockSecret = "yudaoyuanma";
} }

View File

@ -18,7 +18,6 @@ public class SmsSendSingleToUserReqDTO {
/** /**
* 用户编号 * 用户编号
*/ */
@NotNull(message = "用户编号不能为空")
private Long userId; private Long userId;
/** /**
* 手机号 * 手机号

View File

@ -28,7 +28,7 @@ public class SmsChannelBaseVO {
@NotNull(message = "短信 API 的账号不能为空") @NotNull(message = "短信 API 的账号不能为空")
private String apiKey; private String apiKey;
@ApiModelProperty(value = "短信 API 的", example = "yuanma") @ApiModelProperty(value = "短信 API 的", example = "yuanma")
private String apiSecret; private String apiSecret;
@ApiModelProperty(value = "短信发送回调 URL", example = "http://www.iocoder.cn") @ApiModelProperty(value = "短信发送回调 URL", example = "http://www.iocoder.cn")

View File

@ -49,7 +49,7 @@ public class SmsChannelDO extends BaseDO {
*/ */
private String apiKey; private String apiKey;
/** /**
* 短信 API * 短信 API
*/ */
private String apiSecret; private String apiSecret;
/** /**

File diff suppressed because one or more lines are too long

View File

@ -29,14 +29,14 @@
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label-width="180px" label="商户钥" prop="weChatConfig.mchKey" <el-form-item label-width="180px" label="商户钥" prop="weChatConfig.mchKey"
v-if="form.weChatConfig.apiVersion === 'v2'"> v-if="form.weChatConfig.apiVersion === 'v2'">
<el-input v-model="form.weChatConfig.mchKey" placeholder="请输入商户钥" clearable <el-input v-model="form.weChatConfig.mchKey" placeholder="请输入商户钥" clearable
:style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input>
</el-form-item> </el-form-item>
<div v-if="form.weChatConfig.apiVersion === 'v3'"> <div v-if="form.weChatConfig.apiVersion === 'v3'">
<el-form-item label-width="180px" label="API V3钥" prop="weChatConfig.apiV3Key"> <el-form-item label-width="180px" label="API V3钥" prop="weChatConfig.apiV3Key">
<el-input v-model="form.weChatConfig.apiV3Key" placeholder="请输入API V3钥" clearable <el-input v-model="form.weChatConfig.apiV3Key" placeholder="请输入API V3钥" clearable
:style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input> :style="{width: '100%'}" type="textarea" :autosize="{minRows: 8, maxRows: 8}"></el-input>
</el-form-item> </el-form-item>
<el-form-item label-width="180px" label="apiclient_key.perm证书" prop="weChatConfig.privateKeyContent"> <el-form-item label-width="180px" label="apiclient_key.perm证书" prop="weChatConfig.privateKeyContent">
@ -164,7 +164,7 @@ export default {
}], }],
'weChatConfig.mchKey': [{ 'weChatConfig.mchKey': [{
required: true, required: true,
message: '请输入商户钥', message: '请输入商户钥',
trigger: 'blur' trigger: 'blur'
}], }],
'weChatConfig.privateKeyContent': [{ 'weChatConfig.privateKeyContent': [{
@ -179,7 +179,7 @@ export default {
}], }],
'weChatConfig.apiV3Key': [{ 'weChatConfig.apiV3Key': [{
required: true, required: true,
message: '请上传apiV3钥值', message: '请上传apiV3钥值',
trigger: 'blur' trigger: 'blur'
}], }],
}, },

View File

@ -39,7 +39,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="scope.row.code"/> <dict-tag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="scope.row.code"/>
</template> </template>
</el-table-column>> </el-table-column>
<el-table-column label="启用状态" align="center" prop="status"> <el-table-column label="启用状态" align="center" prop="status">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
@ -47,7 +47,7 @@
</el-table-column>> </el-table-column>>
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="短信 API 的账号" align="center" prop="apiKey" /> <el-table-column label="短信 API 的账号" align="center" prop="apiKey" />
<el-table-column label="短信 API 的钥" align="center" prop="apiSecret" /> <el-table-column label="短信 API 的钥" align="center" prop="apiSecret" />
<el-table-column label="短信发送回调 URL" align="center" prop="callbackUrl" /> <el-table-column label="短信发送回调 URL" align="center" prop="callbackUrl" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
@ -68,13 +68,16 @@
@pagination="getList"/> @pagination="getList"/>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="130px">
<el-form-item label="短信签名" prop="signature"> <el-form-item label="短信签名" prop="signature">
<el-input v-model="form.signature" placeholder="请输入短信签名" /> <el-input v-model="form.signature" placeholder="请输入短信签名" />
</el-form-item> </el-form-item>
<el-form-item label="渠道编码" prop="code"> <el-form-item label="渠道编码" prop="code">
<el-input v-model="form.code" placeholder="请输入渠道编码" /> <el-select v-model="form.code" placeholder="请选择渠道编码" clearable>
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="启用状态"> <el-form-item label="启用状态">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
@ -88,8 +91,8 @@
<el-form-item label="短信 API 的账号" prop="apiKey"> <el-form-item label="短信 API 的账号" prop="apiKey">
<el-input v-model="form.apiKey" placeholder="请输入短信 API 的账号" /> <el-input v-model="form.apiKey" placeholder="请输入短信 API 的账号" />
</el-form-item> </el-form-item>
<el-form-item label="短信 API 的钥" prop="apiSecret"> <el-form-item label="短信 API 的钥" prop="apiSecret">
<el-input v-model="form.apiSecret" placeholder="请输入短信 API 的钥" /> <el-input v-model="form.apiSecret" placeholder="请输入短信 API 的钥" />
</el-form-item> </el-form-item>
<el-form-item label="短信发送回调 URL" prop="callbackUrl"> <el-form-item label="短信发送回调 URL" prop="callbackUrl">
<el-input v-model="form.callbackUrl" placeholder="请输入短信发送回调 URL" /> <el-input v-model="form.callbackUrl" placeholder="请输入短信发送回调 URL" />