diff --git a/pom.xml b/pom.xml
index 598ff2b..54c3f45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,9 +12,6 @@
cn.zyjblogs
zyjblogs-parent
pom
-
- server/zyjblogs-sms
-
1.0.0
diff --git a/server/zyjblogs-sms/pom.xml b/server/zyjblogs-sms/pom.xml
index 6b3e565..20703a9 100644
--- a/server/zyjblogs-sms/pom.xml
+++ b/server/zyjblogs-sms/pom.xml
@@ -30,6 +30,10 @@
cn.zyjblogs.starter
zyjblogs-mybatisplus-spring-boot-starter
+
+ cn.zyjblogs.starter
+ zyjblogs-redis-spring-boot-starter
+
cn.zyjblogs.starter
zyjblogs-oauth-spring-boot-starter
@@ -38,6 +42,14 @@
com.tencentcloudapi
tencentcloud-sdk-java-sms
+
+ zyjblogs-web-spring-boot-starter
+ cn.zyjblogs.starter
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
com.alibaba.fastjson2
fastjson2
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/SmsApplication.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/SmsApplication.java
new file mode 100644
index 0000000..2f76d6c
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/SmsApplication.java
@@ -0,0 +1,23 @@
+package cn.zyjblogs;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+/**
+ * Copyright (C), 2021, 北京同创永益科技发展有限公司
+ *
+ * @author zhuyijun
+ * @version 3.0.0
+ * @description
+ * @date 2022/8/17 15:53
+ */
+@EnableAsync
+@EnableFeignClients
+@SpringBootApplication
+public class SmsApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(SmsApplication.class, args);
+ }
+}
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/controller/SmsTaskController.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/controller/SmsTaskController.java
new file mode 100644
index 0000000..def1a85
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/controller/SmsTaskController.java
@@ -0,0 +1,27 @@
+package cn.zyjblogs.sms.task.controller;
+
+import cn.zyjblogs.sms.task.dto.SmsTaskDTO;
+import cn.zyjblogs.sms.task.service.SmsTaskService;
+import cn.zyjblogs.sms.task.vo.SmsTaskVO;
+import cn.zyjblogs.starter.common.entity.response.ResponseObject;
+import cn.zyjblogs.starter.common.entity.response.ResponseResult;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author zhuyijun
+ */
+@RestController
+@RequestMapping("/sms")
+@RequiredArgsConstructor
+public class SmsTaskController {
+ private final SmsTaskService smsTaskService;
+
+ @PostMapping("/sendSmsTask")
+ public ResponseObject sendSmsTask(@RequestBody SmsTaskDTO smsTaskDTO){
+ return ResponseResult.success(smsTaskService.sendSmsTask(smsTaskDTO));
+ }
+}
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/dto/SmsTaskDTO.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/dto/SmsTaskDTO.java
index a088f9f..5edbae6 100644
--- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/dto/SmsTaskDTO.java
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/dto/SmsTaskDTO.java
@@ -5,6 +5,7 @@ import cn.zyjblogs.sms.task.constant.TaskStatus;
import cn.zyjblogs.starter.common.entity.dto.Kv;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
+import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -18,6 +19,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
+@Builder
public class SmsTaskDTO {
@ApiModelProperty(value = "主键id")
private String id;
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsSendStatusPO.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsSendStatusPO.java
index aa6aadc..69aaf9b 100644
--- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsSendStatusPO.java
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsSendStatusPO.java
@@ -36,7 +36,7 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
*/
@Data
@NoArgsConstructor
-@TableName("e_sms_send_status")
+@TableName("sms_send_status")
@ApiModel(value = "SmsSendStatus", description = "短信发送状态")
@AllArgsConstructor
@Builder
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsTemplatePO.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsTemplatePO.java
index 5d032fa..46eacf2 100644
--- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsTemplatePO.java
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/po/SmsTemplatePO.java
@@ -31,7 +31,7 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
@NoArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
-@TableName("e_sms_template")
+@TableName("sms_template")
@ApiModel(value = "SmsTemplate", description = "短信模板")
@AllArgsConstructor
public class SmsTemplatePO {
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java
index 5ac6cef..3337791 100644
--- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java
@@ -59,8 +59,8 @@ public class SmsTaskServiceImpl extends ServiceImpl imp
if (data.getSourceType() == null) {
data.setSourceType(SourceType.OTHER);
}
- SmsTemplatePO template = smsTemplateService.getById(data.getId());
- Asserts.isNull(template,"查询不到该模板,请选择正确的短信模板");
+ SmsTemplatePO template = smsTemplateService.getById(data.getTemplateId());
+ Asserts.notNull(template,"查询不到该模板,请选择正确的短信模板");
//1,验证必要参数
Asserts.notEmpty(data.getTelNum(), "请填写短信接收人");
@@ -119,6 +119,7 @@ public class SmsTaskServiceImpl extends ServiceImpl imp
smsSendStatusService.saveBatch(sendStatusList);
}
updateStatus(smsTask.getId(),TaskStatus.SUCCESS);
+ smsTask.setStatus(TaskStatus.SUCCESS);
return BeanUtils.map(smsTask,SmsTaskVO.class);
}
@@ -162,12 +163,21 @@ public class SmsTaskServiceImpl extends ServiceImpl imp
return sb.toString();
}
public static void main(String[] args) {
- List> list = new ArrayList<>();
- list.add(Kv.builder().k("var").v("atg").build());
- list.add(Kv.builder().k("var").v("1234").build());
- list.add(Kv.builder().k("var").v("01").build());
- list.add(Kv.builder().k("var").v("5").build());
- list.add(Kv.builder().k("k").v("$5").build());
+ System.out.println(JSON.toJSONString(SmsTaskDTO.builder()
+ .id("xx010")
+ .draft(false)
+ .sourceType(SourceType.SERVICE)
+ .templateId("1")
+ .topic("登录验证")
+ .templateParams(List.of(Kv.builder().k("code").v("999999").build()))
+ .telNum(List.of("13476152541"))
+ .build()));
+ List> list = new ArrayList<>();
+ list.add(Kv.builder().k("var").v("atg").build());
+ list.add(Kv.builder().k("var").v("1234").build());
+ list.add(Kv.builder().k("var").v("01").build());
+ list.add(Kv.builder().k("var").v("5").build());
+ list.add(Kv.builder().k("k").v("$5").build());
System.out.println(processTemplate("${var}您好!验证码是:${var}(序号${var}),有效时间为${var}分钟。尝试次数: ${k}", ProviderType.ALI.getRegex(), list));
}
}
diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTemplateServiceImpl.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTemplateServiceImpl.java
index dfc49b1..3bec663 100644
--- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTemplateServiceImpl.java
+++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTemplateServiceImpl.java
@@ -4,9 +4,11 @@ import cn.zyjblogs.sms.task.mapper.SmsTemplateMapper;
import cn.zyjblogs.sms.task.po.SmsTemplatePO;
import cn.zyjblogs.sms.task.service.SmsTemplateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
/**
* @author zhuyijun
*/
+@Service
public class SmsTemplateServiceImpl extends ServiceImpl implements SmsTemplateService {
}
diff --git a/server/zyjblogs-sms/src/main/resources/banner.txt b/server/zyjblogs-sms/src/main/resources/banner.txt
new file mode 100644
index 0000000..d686f19
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/resources/banner.txt
@@ -0,0 +1,9 @@
+ ________ ___ ___ ___ ________ ___ ________ ________ ________
+|\_____ \ |\ \ / /||\ \|\ __ \|\ \ |\ __ \|\ ____\|\ ____\
+ \|___/ /| \ \ \/ / /\ \ \ \ \|\ /\ \ \ \ \ \|\ \ \ \___|\ \ \___|_
+ / / / \ \ / /_ \ \ \ \ __ \ \ \ \ \ \\\ \ \ \ __\ \_____ \
+ / /_/__ \/ / /\ \\_\ \ \ \|\ \ \ \____\ \ \\\ \ \ \|\ \|____|\ \
+ |\________\__/ / / \ \________\ \_______\ \_______\ \_______\ \_______\____\_\ \
+ \|_______|\___/ / \|________|\|_______|\|_______|\|_______|\|_______|\_________\
+ \|___|/ \|_________|
+ Release 1.0.0. Powered by zyjblogs-framework 1.0.0.
\ No newline at end of file
diff --git a/server/zyjblogs-sms/src/main/resources/bootstrap-test.yml b/server/zyjblogs-sms/src/main/resources/bootstrap-test.yml
new file mode 100644
index 0000000..ca0d427
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/resources/bootstrap-test.yml
@@ -0,0 +1,8 @@
+zyjblogs:
+ config:
+ nacos:
+ host: ${ZYJBLOGS_CONFIG_NACOS_HOST:127.0.0.1}
+ port: ${ZYJBLOGS_CONFIG_NACOS_PORT:8848}
+ username: ${ZYJBLOGS_CONFIG_NACOS_USERNAME:nacos}
+ password: ${ZYJBLOGS_CONFIG_NACOS_PASSWORD:nacos}
+
diff --git a/server/zyjblogs-sms/src/main/resources/bootstrap.yml b/server/zyjblogs-sms/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..f58b231
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/resources/bootstrap.yml
@@ -0,0 +1,111 @@
+spring:
+ profiles:
+ active: test
+
+---
+
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: zyjblogs-sms
+ redis:
+ host: 127.0.0.1
+ port: 6379
+ password:
+ timeout: 10000 #连接超时时间(毫秒)
+ lettuce:
+ pool:
+ max-active: 8 # 连接池最大连接数
+ max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
+ min-idle: 0 # 连接池中的最小空闲连接
+ max-idle: 8 # 连接池中的最大空闲连接
+ cloud:
+ nacos:
+ config:
+ server-addr: ${zyjblogs.config.nacos.host}:${zyjblogs.config.nacos.port}
+ username: ${zyjblogs.config.nacos.username}
+ password: ${zyjblogs.config.nacos.password}
+ namespace: ${spring.profiles.active}
+ group: public
+ file-extension: yml
+ shared-configs[0]:
+ data-id: zyjblogs-global-${spring.profiles.active}.yml
+ group: global
+ refresh: true
+ discovery:
+ server-addr: ${spring.cloud.nacos.config.server-addr}
+ username: ${spring.cloud.nacos.config.username}
+ password: ${spring.cloud.nacos.config.password}
+ namespace: ${spring.cloud.nacos.config.namespace}
+ group: public
+ sharding-sphere:
+ datasource:
+ names: write-ds,read-ds-0
+ write-ds:
+ jdbc-url: jdbc:mysql://127.0.0.1:3306/zyjblogs_sms?allowPublicKeyRetrieval=true&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+ type: com.zaxxer.hikari.HikariDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ password: 123456
+ connectionTimeoutMilliseconds: 3000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+ maintenanceIntervalMilliseconds: 30000\
+ hikari:
+ minimum-idle: 10
+ maximum-pool-size: 100
+ auto-commit: true
+ idle-timeout: 1800000
+ pool-name: DatebookHikariCP
+ max-lifetime: 1800000
+ connection-timeout: 60000
+ connection-test-query: SELECT 1
+ read-ds-0:
+ jdbc-url: jdbc:mysql://127.0.0.1:3306/zyjblogs_sms?allowPublicKeyRetrieval=true&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+ type: com.zaxxer.hikari.HikariDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: read
+ password: 123456
+ connectionTimeoutMilliseconds: 3000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 1
+ maintenanceIntervalMilliseconds: 30000
+ hikari:
+ minimum-idle: 10
+ maximum-pool-size: 100
+ auto-commit: true
+ idle-timeout: 1800000
+ pool-name: DatebookHikariCP
+ max-lifetime: 1800000
+ connection-timeout: 60000
+ connection-test-query: SELECT 1
+ sharding:
+ master-slave-rules:
+ master0:
+ master-data-source-name: write-ds
+ slave-data-source-names: read-ds-0
+ props:
+ sql:
+ show: true
+
+logging:
+ config: classpath:logback-spring.xml
+
+security:
+ oauth2:
+ client:
+ client-id: ${spring.application.name}
+ client-secret: secret
+ scope: user
+ resource:
+ id: ${spring.application.name}
+rsa:
+ key:
+ enable: true
+ pubKey-path: public.txt
+ priKey-path: private.txt
diff --git a/server/zyjblogs-sms/src/main/resources/logback-spring.xml b/server/zyjblogs-sms/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..51f3170
--- /dev/null
+++ b/server/zyjblogs-sms/src/main/resources/logback-spring.xml
@@ -0,0 +1,198 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ info
+
+
+ ${CONSOLE_LOG_PATTERN}
+ UTF-8
+
+
+
+
+
+
+ ${logger.path}/log_debug.log
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${logger.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log
+ 50MB
+
+ 30
+ 1GB
+ true
+
+
+
+
+ debug
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${logger.path}/log_info.log
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${logger.path}/info/log-info-%d{yyyy-MM-dd}.%i.log
+ 50MB
+
+ 30
+ 1GB
+ true
+
+
+
+ info
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${logger.path}/log_warn.log
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${logger.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log
+ 50MB
+
+ 30
+ 1GB
+ true
+
+
+
+ warn
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${logger.path}/log_error.log
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{traceId}] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${logger.path}/error/log-error-%d{yyyy-MM-dd}.%i.log
+ 50MB
+
+ 30
+ 1GB
+ true
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/RsaKeyProperties.java b/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/RsaKeyProperties.java
index 8fd07e3..db951c8 100644
--- a/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/RsaKeyProperties.java
+++ b/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/RsaKeyProperties.java
@@ -19,7 +19,7 @@ public class RsaKeyProperties {
/**
* 启用rsa对token进行加密
*/
- private Boolean enable;
+ private Boolean enable = true;
/**
* 公钥地址
diff --git a/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/WhiteListProperties.java b/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/WhiteListProperties.java
index 9dac4ce..7a9d6b2 100644
--- a/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/WhiteListProperties.java
+++ b/stater/zyjblogs-oauth-spring-boot-starter/src/main/java/cn/zyjblogs/starter/oauth/autoconfigure/WhiteListProperties.java
@@ -4,6 +4,7 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -16,5 +17,5 @@ import java.util.List;
@ConfigurationProperties(prefix = "zyjblogs.whilelist")
public class WhiteListProperties {
- private List allowPaths;
+ private List allowPaths = new LinkedList<>();
}