package com.ruoyi.message.config;
|
|
import lombok.Data;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* 消息发送模块配置(统一入口)。
|
* <p>
|
* 由两块拼成,<b>不要合并</b>:
|
* <ul>
|
* <li>存量配置({@code xhsmsPath} / {@code sms_accountName} / {@code accessKeyId} / {@code signName} ...)
|
* → {@link RootMessageProperties},字段名与 yml key 完全同名;</li>
|
* <li>新增项(原先硬编码在代码里、本次提为可配置的地址/密钥/文案)→ 本类的
|
* {@code message.sms.*} / {@code message.wechat.*} 前缀项。</li>
|
* </ul>
|
* 对业务代码只暴露分组的 {@code getSms()} / {@code getWechat()},屏蔽两种绑定的差异。
|
* <p>
|
* ⚠️ {@code getSms()} 是手写 getter,每次调用会把存量扁平字段合并进分组对象;这是幂等的,
|
* 因此即使被调用多次也没有副作用。
|
*/
|
@Component
|
@ConfigurationProperties(prefix = "message")
|
public class MessageProperties {
|
|
private final RootMessageProperties root;
|
|
/** 绑定 {@code message.sms.*} */
|
private Sms sms = new Sms();
|
|
/** 绑定 {@code message.wechat.*} */
|
private Wechat wechat = new Wechat();
|
|
@Autowired
|
public MessageProperties(RootMessageProperties root) {
|
this.root = root;
|
}
|
|
public RootMessageProperties getRoot() {
|
return root;
|
}
|
|
/**
|
* 短信配置统一入口:存量扁平项 + 新增项
|
*/
|
public Sms getSms() {
|
this.sms.setXhsms(buildXhsms());
|
this.sms.setMt(buildMt());
|
this.sms.setAliyun(buildAliyun());
|
return this.sms;
|
}
|
|
public void setSms(Sms sms) {
|
this.sms = sms;
|
}
|
|
/**
|
* 微信公众号配置统一入口
|
*/
|
public Wechat getWechat() {
|
return this.wechat;
|
}
|
|
public void setWechat(Wechat wechat) {
|
this.wechat = wechat;
|
}
|
|
private XhsmsConfig buildXhsms() {
|
XhsmsConfig xhsms = new XhsmsConfig();
|
xhsms.setPath(root.getXhsmsPath());
|
xhsms.setAccount(root.getXhsmsAccount());
|
xhsms.setPwd(root.getXhsmsPwd());
|
xhsms.setExtno(root.getXhsmsjrm());
|
return xhsms;
|
}
|
|
private MtSmsConfig buildMt() {
|
MtSmsConfig mt = new MtSmsConfig();
|
mt.setAccountName(root.getSmsAccountName());
|
mt.setPassword(root.getSmsPassword());
|
mt.setUrl(root.getSmsUrl());
|
mt.setSourceAddr(root.getSmsSourceAddr());
|
mt.setServiceCode(root.getSmsServiceCode());
|
mt.setAppkey(root.getSmsAppkey());
|
mt.setFlag(root.getSmsFlag());
|
return mt;
|
}
|
|
private AliyunSmsConfig buildAliyun() {
|
AliyunSmsConfig aliyun = new AliyunSmsConfig();
|
aliyun.setAccessKeyId(root.getAccessKeyId());
|
aliyun.setAccessKeySecret(root.getAccessKeySecret());
|
aliyun.setSignName(root.getSignName());
|
return aliyun;
|
}
|
|
/**
|
* 短信配置分组
|
*/
|
@Data
|
public static class Sms {
|
|
private XhsmsConfig xhsms = new XhsmsConfig();
|
|
private MtSmsConfig mt = new MtSmsConfig();
|
|
private AliyunSmsConfig aliyun = new AliyunSmsConfig();
|
|
private ShiyiSms shiyi = new ShiyiSms();
|
|
private MessagingInsert messagingInsert = new MessagingInsert();
|
}
|
|
/**
|
* 杭州市一 HIS 服务平台短信(shiyi-his 通道)
|
*/
|
@Data
|
public static class ShiyiSms {
|
|
/**
|
* HIS RunService 地址。
|
* <p>
|
* TODO 待确认:原实现把 {@code http://192.178.0.104:7790/MediInfoHis.svc} 硬编码在
|
* {@code ShiyiSmsUtil.invokeRunService} 里,这里提为可配置,默认值与原硬编码保持一致。
|
*/
|
private String wsUrl = "http://192.178.0.104:7790/MediInfoHis.svc";
|
|
/**
|
* 默认操作员代码
|
*/
|
private String defaultCaozuoydm;
|
|
/**
|
* 默认操作员姓名
|
*/
|
private String defaultCaozuoyxm;
|
|
/**
|
* 短信签名前缀(当前未使用,留给后续需要时)
|
*/
|
private String sign = "";
|
}
|
|
/**
|
* 预约挂号短信平台(MessagingInsert,Axis SOAP12)
|
*/
|
@Data
|
public static class MessagingInsert {
|
|
/**
|
* SOAP 服务地址。
|
* <p>
|
* TODO 待确认:原实现把 {@code http://218.108.11.29:8081/MessagingInsert.asmx} 硬编码在
|
* {@code MessagingInsertLocator} 生成的代码里,这里提为可配置,默认值与原硬编码一致。
|
*/
|
private String wsUrl = "http://218.108.11.29:8081/MessagingInsert.asmx";
|
}
|
|
/**
|
* 微信公众号相关配置
|
*/
|
@Data
|
public static class Wechat {
|
|
private ShiyiWechat shiyi = new ShiyiWechat();
|
|
private Xinhua xinhua = new Xinhua();
|
}
|
|
/**
|
* 市一微信公众号(hzszlyy 通道)
|
*/
|
@Data
|
public static class ShiyiWechat {
|
|
/**
|
* 接口地址。
|
* <p>
|
* TODO 待确认:原 {@code smsUtils.sendChat} 把 {@code http://192.200.54.14:5003/sfjk/SendMessage}
|
* 硬编码在方法里,这里提为可配置,默认值与原硬编码保持一致。
|
*/
|
private String url = "http://192.200.54.14:5003/sfjk/SendMessage";
|
|
/**
|
* 接口密钥。
|
* <p>
|
* TODO 待确认:原 {@code smsUtils.sendChat} 把 key
|
* {@code ff76f8904f5f32b5ee1739e8ea46e60g} 硬编码在方法里,此值疑似为占位/测试密钥,请业务确认后替换。
|
*/
|
private String key = "ff76f8904f5f32b5ee1739e8ea46e60g";
|
|
/**
|
* 消息标题。
|
* <p>
|
* TODO 待确认:原实现把「您好,邀请您填写出院调查表,请点击填写。」写死在 URL 里,
|
* 所有外部链接(随访/问卷/宣教)都用同一句文案,这里提为可配置,默认值与原文案一致。
|
*/
|
private String title = "您好,邀请您填写出院调查表,请点击填写。";
|
|
/**
|
* 消息内容占位。
|
* <p>
|
* TODO 待确认:原实现写死为「待随访」,此处默认值与原值一致。
|
*/
|
private String content = "待随访";
|
}
|
|
/**
|
* 新华微信公众号(xh 通道)
|
*/
|
@Data
|
public static class Xinhua {
|
|
/**
|
* 接口服务名,固定值。
|
* <p>
|
* 原 {@code XinHuaWXReq.service} 默认 {@code smarthos.pat.notice}
|
*/
|
private String service = "smarthos.pat.notice";
|
}
|
}
|