Commit bf62185f by levphon

通知服务-新增发短信接口

1 parent b1936c9f
...@@ -16,9 +16,20 @@ public class MessageTemplate extends BaseEntity { ...@@ -16,9 +16,20 @@ public class MessageTemplate extends BaseEntity {
private String content; private String content;
/**
* 消息类型:短信SMS、邮件MAIL、公众号WXMP、小程序WXMA
*/
@Column(name = "send_type") @Column(name = "send_type")
private String sendType; private String sendType;
/**
* 短信发送通道
*/
private String source;
/**
* 消息类型:根据send_type具体来看 短信类型:1:通知短信;2验证码短信
*/
private Integer type; private Integer type;
} }
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,7 @@ import cn.com.glsx.notify.modules.entity.MessageTemplate; ...@@ -6,6 +6,7 @@ import cn.com.glsx.notify.modules.entity.MessageTemplate;
import cn.com.glsx.notify.modules.mapper.MessageLogMapper; import cn.com.glsx.notify.modules.mapper.MessageLogMapper;
import cn.com.glsx.notify.modules.mapper.MessageTemplateMapper; import cn.com.glsx.notify.modules.mapper.MessageTemplateMapper;
import cn.com.glsx.notify.modules.utils.RopHttpUtil; import cn.com.glsx.notify.modules.utils.RopHttpUtil;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.sms.properties.SMSProperties; import com.glsx.plat.sms.properties.SMSProperties;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -47,12 +48,16 @@ public class SmsService { ...@@ -47,12 +48,16 @@ public class SmsService {
log.warn("短信模板{}不存在", template); log.warn("短信模板{}不存在", template);
return; return;
} }
if (StringUtils.isNullOrEmpty(mt.getSource())) {
log.warn("短信模板{}发送通道为空", template);
return;
}
String content = MessageFormat.format(mt.getContent(), arg); String content = MessageFormat.format(mt.getContent(), arg);
String[] phones = phone.split(";"); String[] phones = phone.split(";");
Arrays.asList(phones).forEach(pno -> sendMessage(pno, String.valueOf(mt.getType()), content)); Arrays.asList(phones).forEach(pno -> sendMessage(pno, mt.getSource(), String.valueOf(mt.getType()), content));
MessageLog log = new MessageLog(); MessageLog log = new MessageLog();
log.setToUser(phone); log.setToUser(phone);
...@@ -67,15 +72,16 @@ public class SmsService { ...@@ -67,15 +72,16 @@ public class SmsService {
* 发送短信 * 发送短信
* *
* @param phone 电话号码,批量用逗号隔开 * @param phone 电话号码,批量用逗号隔开
* @param source 发送通道
* @param type 类型 * @param type 类型
* @param context 发送内容 * @param context 发送内容
*/ */
public void sendMessage(String phone, String type, String context) { public void sendMessage(String phone, String source, String type, String context) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(5); MultiValueMap<String, String> params = new LinkedMultiValueMap<>(5);
try { try {
params.add("phone", phone); params.add("phone", phone);
params.add("source", properties.getSource()); params.add("source", source);
params.add("messageSource", properties.getSource()); params.add("messageSource", source);
params.add("type", type); params.add("type", type);
params.add("context", context); params.add("context", context);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<result column="subject" jdbcType="VARCHAR" property="subject"/> <result column="subject" jdbcType="VARCHAR" property="subject"/>
<result column="content" jdbcType="VARCHAR" property="content"/> <result column="content" jdbcType="VARCHAR" property="content"/>
<result column="send_type" jdbcType="VARCHAR" property="sendType"/> <result column="send_type" jdbcType="VARCHAR" property="sendType"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<result column="type" jdbcType="INTEGER" property="type"/> <result column="type" jdbcType="INTEGER" property="type"/>
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/> <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/> <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
...@@ -21,7 +22,7 @@ ...@@ -21,7 +22,7 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, `template`, subject, content, send_type, `type`, del_flag, created_date, id, `template`, subject, content, send_type, `source`, `type`, del_flag, created_date,
created_by, updated_date, updated_by created_by, updated_date, updated_by
</sql> </sql>
<select id="findByTemplate" resultMap="BaseResultMap"> <select id="findByTemplate" resultMap="BaseResultMap">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!