parent
eb99631e91
commit
2f7ac4d427
@ -0,0 +1,42 @@
|
||||
package com.java3y.austin.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 发送渠道类型枚举
|
||||
*/
|
||||
public enum ChannelType {
|
||||
IM(10, "IM(站内信)"),
|
||||
PUSH(20, "push(通知栏)"),
|
||||
SMS(30, "sms(短信)"),
|
||||
EMAIL(40, "email(邮件)"),
|
||||
OFFICIAL_ACCOUNT(50, "OfficialAccounts(服务号)"),
|
||||
MINI_PROGRAM(60, "miniProgram(小程序)")
|
||||
;
|
||||
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
ChannelType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.java3y.austin.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 发送ID类型枚举
|
||||
*/
|
||||
public enum IdType {
|
||||
USER_ID(10, "userid"),
|
||||
DID(20, "did"),
|
||||
PHONE(30, "phone"),
|
||||
OPEN_ID(40, "openId"),
|
||||
EMAIL(50, "email");
|
||||
|
||||
IdType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.java3y.austin.enums;
|
||||
|
||||
/**
|
||||
* 发送的消息类型
|
||||
*/
|
||||
public enum MessageType {
|
||||
NOTICE(10,"通知类消息"),
|
||||
MARKETING(20,"营销类消息"),
|
||||
AUTH_CODE(30,"验证码消息")
|
||||
;
|
||||
|
||||
/**
|
||||
* `msg_type` tinyint(4)
|
||||
* NOT NULL DEFAULT '0' COMMENT '10.通知类消息 20.营销类消息 30.验证码类消息',
|
||||
*/
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
MessageType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.java3y.austin.enums;
|
||||
|
||||
public enum SmsStatus {
|
||||
|
||||
SEND_SUCCESS(10,"调用渠道接口发送成功"),
|
||||
RECEIVE_SUCCESS(20,"用户收到短信(收到渠道短信回执,状态成功)"),
|
||||
RECEIVE_FAIL(30, "用户收不到短信(收到渠道短信回执,状态失败)");
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
SmsStatus(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.java3y.austin.enums;
|
||||
|
||||
public enum TemplateType {
|
||||
|
||||
OPERATION(10, "运营类的模板"),
|
||||
TECHNOLOGY(20, "技术类的模板"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
TemplateType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.java3y.austin.handler;
|
||||
|
||||
import com.java3y.austin.domain.MessageTemplate;
|
||||
import com.java3y.austin.pojo.TaskInfo;
|
||||
|
||||
public interface Handler {
|
||||
|
||||
boolean doHandler(TaskInfo TaskInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.java3y.austin.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.java3y.austin.dao.SmsRecordDao;
|
||||
import com.java3y.austin.domain.MessageTemplate;
|
||||
import com.java3y.austin.domain.SmsRecord;
|
||||
import com.java3y.austin.pojo.SmsParam;
|
||||
import com.java3y.austin.pojo.TaskInfo;
|
||||
import com.java3y.austin.script.SmsScript;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class SmsHandler implements Handler {
|
||||
@Autowired
|
||||
private SmsRecordDao smsRecordDao;
|
||||
|
||||
@Autowired
|
||||
private SmsScript smsScript;
|
||||
|
||||
@Override
|
||||
public boolean doHandler(TaskInfo taskInfo) {
|
||||
|
||||
SmsParam smsParam = SmsParam.builder()
|
||||
.phones(taskInfo.getReceiver())
|
||||
.content(taskInfo.getContent())
|
||||
.messageTemplateId(taskInfo.getMessageTemplateId())
|
||||
.supplierId(10)
|
||||
.supplierName("腾讯云通知类消息渠道").build();
|
||||
List<SmsRecord> recordList = smsScript.send(smsParam);
|
||||
|
||||
if (CollUtil.isNotEmpty(recordList)) {
|
||||
smsRecordDao.saveAll(recordList);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.java3y.austin.script;
|
||||
|
||||
import com.java3y.austin.domain.SmsRecord;
|
||||
import com.java3y.austin.pojo.SmsParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SmsScript {
|
||||
|
||||
|
||||
/**
|
||||
* @param smsParam 发送短信参数
|
||||
* @return 渠道商接口返回值
|
||||
*/
|
||||
List<SmsRecord> send(SmsParam smsParam);
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.java3y.austin.dao;
|
||||
|
||||
import com.java3y.austin.domain.MessageTemplate;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface MessageTemplateDao extends CrudRepository<MessageTemplate, Long> {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.java3y.austin.dao;
|
||||
|
||||
import com.java3y.austin.domain.SmsRecord;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface SmsRecordDao extends CrudRepository<SmsRecord, Long> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.java3y.austin.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.java3y.austin.dao.MessageTemplateDao;
|
||||
import com.java3y.austin.domain.MessageTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
public class MessageTemplateController {
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateDao messageTemplateDao;
|
||||
|
||||
/**
|
||||
* test insert
|
||||
*/
|
||||
@GetMapping("/insert")
|
||||
public String insert() {
|
||||
|
||||
MessageTemplate messageTemplate = MessageTemplate.builder()
|
||||
.name("test短信")
|
||||
.auditStatus(10)
|
||||
.flowId("yyyy")
|
||||
.msgStatus(10)
|
||||
.idType(10)
|
||||
.sendChannel(10)
|
||||
.templateType(10)
|
||||
.msgType(10)
|
||||
.expectPushTime("0")
|
||||
.msgContent("3333333m")
|
||||
.sendAccount(66)
|
||||
.creator("yyyyc")
|
||||
.updator("yyyyu")
|
||||
.team("yyyt")
|
||||
.proposer("yyyy22")
|
||||
.auditor("yyyyyyz")
|
||||
.isDeleted(0)
|
||||
.created(Math.toIntExact(DateUtil.currentSeconds()))
|
||||
.updated(Math.toIntExact(DateUtil.currentSeconds()))
|
||||
.deduplicationTime(1)
|
||||
.isNightShield(0)
|
||||
.build();
|
||||
|
||||
MessageTemplate info = messageTemplateDao.save(messageTemplate);
|
||||
|
||||
return JSON.toJSONString(info);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* test query
|
||||
*/
|
||||
@GetMapping("/query")
|
||||
public String query() {
|
||||
Iterable<MessageTemplate> all = messageTemplateDao.findAll();
|
||||
for (MessageTemplate messageTemplate : all) {
|
||||
return JSON.toJSONString(messageTemplate);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.java3y.austin.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.java3y.austin.handler.SmsHandler;
|
||||
import com.java3y.austin.pojo.SmsParam;
|
||||
import com.java3y.austin.pojo.TaskInfo;
|
||||
import com.java3y.austin.script.TencentSmsScript;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@RestController
|
||||
public class SendController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SmsHandler smsHandler;
|
||||
|
||||
/**
|
||||
* 测试发送短信
|
||||
* @param phone 手机号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sendSms")
|
||||
public boolean sendSms(String phone,String content,Long messageTemplateId ) {
|
||||
|
||||
TaskInfo taskInfo = TaskInfo.builder().receiver(new HashSet<>(Arrays.asList(phone)))
|
||||
.content(content).messageTemplateId(messageTemplateId).build();
|
||||
|
||||
return smsHandler.doHandler(taskInfo);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.java3y.austin.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.java3y.austin.dao.SmsRecordDao;
|
||||
import com.java3y.austin.domain.MessageTemplate;
|
||||
import com.java3y.austin.domain.SmsRecord;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
public class SmsRecordController {
|
||||
|
||||
@Autowired
|
||||
private SmsRecordDao smsRecordDao;
|
||||
|
||||
/**
|
||||
* test insert
|
||||
*/
|
||||
@GetMapping("/insert")
|
||||
public String insert(Integer phone) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* test query
|
||||
*/
|
||||
@GetMapping("/query")
|
||||
public String query() {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,18 +1,29 @@
|
||||
# HTTP 连接配置 TODO
|
||||
# HTTP 连接配置 T0D0
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
keep-alive-duration: 300
|
||||
max-idle-connections: 200
|
||||
read-timeout: 30
|
||||
write-timeout: 30
|
||||
http:
|
||||
connect-timeout: 30
|
||||
keep-alive-duration: 300
|
||||
max-idle-connections: 200
|
||||
read-timeout: 30
|
||||
write-timeout: 30
|
||||
|
||||
# 腾讯云账号相关的信息配置 TODO
|
||||
tencent:
|
||||
sms:
|
||||
account:
|
||||
secret-id:
|
||||
secret-key:
|
||||
sign_name:
|
||||
sms-sdk-app-id:
|
||||
template-id:
|
||||
sms:
|
||||
account:
|
||||
secret-id:
|
||||
secret-key:
|
||||
sign_name:
|
||||
sms-sdk-app-id:
|
||||
template-id:
|
||||
|
||||
|
||||
# 数据库相关的信息配置 TODO
|
||||
spring:
|
||||
datasource:
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
driver-class-name:
|
||||
|
||||
# tomcat / HikariPool(数据库连接池 配置) TODO
|
Loading…
Reference in new issue