mpNewsArticles = JSON.parseArray(contentModel.getMpNewsArticle(), MpnewsArticle.class);
+ wxCpMessage = WxCpMessage.MPNEWS().articles(mpNewsArticles).build();
+ } else if (SendMessageType.MARKDOWN.getCode().equals(contentModel.getSendType())) {
+ wxCpMessage = WxCpMessage.MARKDOWN().content(contentModel.getContent()).build();
+ } else if (SendMessageType.MINI_PROGRAM_NOTICE.getCode().equals(contentModel.getSendType())) {
+ Map contentItems = JSON.parseObject(contentModel.getContentItems(), Map.class);
+ wxCpMessage = WxCpMessage.newMiniProgramNoticeBuilder().appId(contentModel.getAppId()).page(contentModel.getPage()).emphasisFirstItem(contentModel.getEmphasisFirstItem()).contentItems(contentItems).title(contentModel.getTitle()).description(contentModel.getDescription()).build();
+ } else if (SendMessageType.TEMPLATE_CARD.getCode().equals(contentModel.getSendType())) {
+ // WxJava 未支持
+ }
+ wxCpMessage.setAgentId(agentId);
+ wxCpMessage.setToUser(userId);
+ return wxCpMessage;
}
+
@Override
public void recall(MessageTemplate messageTemplate) {
diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/SmsHandler.java b/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/SmsHandler.java
index 7e8b336..d8cd98f 100644
--- a/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/SmsHandler.java
+++ b/austin-handler/src/main/java/com/java3y/austin/handler/handler/impl/SmsHandler.java
@@ -19,6 +19,7 @@ import com.java3y.austin.handler.script.SmsScriptHolder;
import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord;
+import com.java3y.austin.support.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -45,8 +46,8 @@ public class SmsHandler extends BaseHandler implements Handler {
@Autowired
private SmsScriptHolder smsScriptHolder;
- @ApolloConfig("boss.austin")
- private Config config;
+ @Autowired
+ private ConfigService config;
@Override
@@ -116,7 +117,7 @@ public class SmsHandler extends BaseHandler implements Handler {
* 每种类型都会有其下发渠道账号的配置(流量占比也会配置里面)
*
* 样例:
- * key:msg_type_sms_config
+ * key:msgTypeSmsConfig
* value:[{"message_type_10":[{"weights":80,"scriptName":"TencentSmsScript"},{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
* 通知类短信有两个发送渠道 TencentSmsScript 占80%流量,YunPianSmsScript占20%流量
* 营销类短信只有一个发送渠道 YunPianSmsScript
@@ -127,7 +128,7 @@ public class SmsHandler extends BaseHandler implements Handler {
*/
private List getMessageTypeSmsConfig(Integer msgType) {
- String apolloKey = "msg_type_sms_config";
+ String apolloKey = "msgTypeSmsConfig";
String messagePrefix = "message_type_";
String property = config.getProperty(apolloKey, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_ARRAY);
diff --git a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java
index 6dec68c..1c7d4d1 100644
--- a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java
+++ b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/config/PipelineConfig.java
@@ -49,7 +49,7 @@ public class PipelineConfig {
}
/**
- * 普通发送执行流程
+ * 消息撤回执行流程
* 1.组装参数
* 2.发送MQ
* @return
@@ -63,9 +63,7 @@ public class PipelineConfig {
/**
* pipeline流程控制器
- * 目前暂定只有 普通发送的流程
* 后续扩展则加BusinessCode和ProcessTemplate
- *
* @return
*/
@Bean
diff --git a/austin-support/src/main/java/com/java3y/austin/support/service/ConfigService.java b/austin-support/src/main/java/com/java3y/austin/support/service/ConfigService.java
new file mode 100644
index 0000000..29b37f2
--- /dev/null
+++ b/austin-support/src/main/java/com/java3y/austin/support/service/ConfigService.java
@@ -0,0 +1,21 @@
+package com.java3y.austin.support.service;
+
+
+/**
+ * 读取配置服务
+ *
+ * @author 3y
+ */
+public interface ConfigService {
+
+ /**
+ * 读取配置
+ * 1、当启动使用了apollo,优先读取apollo
+ * 2、当没有启动apollo,读取本地 local.properties 配置文件的内容
+ * @param key
+ * @param defaultValue
+ * @return
+ */
+ String getProperty(String key, String defaultValue);
+
+}
diff --git a/austin-support/src/main/java/com/java3y/austin/support/service/impl/ConfigServiceImpl.java b/austin-support/src/main/java/com/java3y/austin/support/service/impl/ConfigServiceImpl.java
new file mode 100644
index 0000000..f163d72
--- /dev/null
+++ b/austin-support/src/main/java/com/java3y/austin/support/service/impl/ConfigServiceImpl.java
@@ -0,0 +1,41 @@
+package com.java3y.austin.support.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.setting.dialect.Props;
+import com.ctrip.framework.apollo.Config;
+import com.java3y.austin.support.service.ConfigService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @author 3y
+ * 读取配置实现类
+ */
+@Service
+public class ConfigServiceImpl implements ConfigService {
+
+ /**
+ * 本地配置
+ */
+ private static final String PROPERTIES_PATH = "local.properties";
+ private Props props = new Props(PROPERTIES_PATH);
+
+ /**
+ * apollo配置
+ */
+ @Value("${apollo.bootstrap.enabled}")
+ private Boolean enableApollo;
+ @Value("${apollo.bootstrap.namespaces}")
+ private String namespaces;
+
+ @Override
+ public String getProperty(String key, String defaultValue) {
+ if (enableApollo) {
+ Config config = com.ctrip.framework.apollo.ConfigService.getConfig(namespaces.split(StrUtil.COMMA)[0]);
+ return config.getProperty(key, defaultValue);
+ } else {
+ return props.getProperty(key, defaultValue);
+ }
+ }
+}
diff --git a/austin-support/src/main/java/com/java3y/austin/support/utils/AccountUtils.java b/austin-support/src/main/java/com/java3y/austin/support/utils/AccountUtils.java
index b72b952..922c02b 100644
--- a/austin-support/src/main/java/com/java3y/austin/support/utils/AccountUtils.java
+++ b/austin-support/src/main/java/com/java3y/austin/support/utils/AccountUtils.java
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.java3y.austin.common.constant.AustinConstant;
+import com.java3y.austin.support.service.ConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@@ -14,15 +16,14 @@ import org.springframework.stereotype.Component;
* @author 3y
*/
@Component
-
public class AccountUtils {
- @ApolloConfig("boss.austin")
- private Config config;
+ @Autowired
+ private ConfigService config;
/**
* (key:smsAccount)短信参数示例:[{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"AKIDhDxxxxxxxx1WljQq","secretKey":"B4hwww39yxxxrrrrgxyi","smsSdkAppId":"1423123125","templateId":"1182097","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"caffff8234234231b5cd7","tpl_id":"523333332","supplierId":20,"supplierName":"云片"}}]
- * (key:emailAccount)邮件参数示例:[{"email_10":{"host":"smtp.qq.com","port":465,"user":"4032222131@qq.com","pass":"","from":"4036333131@qq.com"}}]
+ * (key:emailAccount)邮件参数示例:[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423423@qq.com","pass":"23423432432423423","from":"234@qq.com","starttlsEnable":true,"auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"22222@163.com","pass":"23432423","from":"234324324234@163.com","starttlsEnable":false,"auth":true,"sslEnable":true}}]
* (key:enterpriseWechatAccount)企业微信参数示例:[{"enterprise_wechat_10":{"corpId":"wwf87603333e00069c","corpSecret":"-IFWxS2222QxzPIorNV11144D915DM","agentId":10044442,"token":"rXROB3333Kf6i","aesKey":"MKZtoFxHIM44444M7ieag3r9ZPUsl"}}]
* (key:dingDingRobotAccount) 钉钉自定义机器人参数示例:[{"ding_ding_robot_10":{"secret":"SEC9222d4768aded74114faae92229de422222fedf","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b6442222203d87333367328b0c3003d164715d2c6c6e56"}}]
* (key:dingDingWorkNoticeAccount) 钉钉工作消息参数示例:[{"ding_ding_work_notice_10":{"appKey":"dingh6yyyyyyycrlbx","appSecret":"tQpvmkR863333yyyyyHP3QHyyyymy9Ao1yoL1oQX5NsdfsWHvWKbTu","agentId":"1523123123183622"}}]
diff --git a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java
index f562187..2f92a06 100644
--- a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java
+++ b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java
@@ -10,7 +10,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AustinApplication {
public static void main(String[] args) {
- // TODO apollo的ip/port【must】
+
+ // TODO 如果你需要使用apollo,将application.properties配置文件的 apollo.enabled 改为true
System.setProperty("apollo.config-service", "http://austin.apollo.config:5001");
SpringApplication.run(AustinApplication.class, args);
}
diff --git a/austin-web/src/main/java/com/java3y/austin/web/vo/UploadResponseVo.java b/austin-web/src/main/java/com/java3y/austin/web/vo/UploadResponseVo.java
index 459e965..de7c0ef 100644
--- a/austin-web/src/main/java/com/java3y/austin/web/vo/UploadResponseVo.java
+++ b/austin-web/src/main/java/com/java3y/austin/web/vo/UploadResponseVo.java
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
/**
* 上传后成功返回素材的Id
+ * @author 3y
*/
@Builder
@Data
diff --git a/austin-web/src/main/resources/application.properties b/austin-web/src/main/resources/application.properties
index 9b8f82e..b3cdaa0 100644
--- a/austin-web/src/main/resources/application.properties
+++ b/austin-web/src/main/resources/application.properties
@@ -17,10 +17,14 @@ austin-redis-ip=austin.redis
austin-redis-port=5003
austin-redis-password=austin
-# todo [xxl-job] ip/port【optional】
+# todo [xxl-job] switch/ip/port/【optional】
+xxl-job.enabled=false
austin-xxl-job-ip=127.0.0.1
austin-xxl-job-port=6767
+# todo [apollo] switch 【optional】
+apollo.enabled=false
+
# todo [grayLog] ip【optional】
austin-grayLog-ip=austin.graylog
@@ -56,7 +60,7 @@ austin.business.recall.topic.name=austinRecall
austin.business.recall.group.name=recallGroupId
austin.business.log.topic.name=austinLog
austin.business.graylog.ip=${austin-grayLog-ip}
-# TODO if windows os ,replace path !
+# TODO if windows os and need upload file to send message ,replace path !
austin.business.upload.crowd.path=/Users/3y/temp
##################### xxl properties #####################
@@ -73,7 +77,7 @@ xxl.job.accessToken=
##################### apollo #####################
app.id=austin
-apollo.bootstrap.enabled=true
+apollo.bootstrap.enabled=${apollo.enabled}
apollo.bootstrap.namespaces=boss.austin,dynamic-tp-apollo-dtp.yml
##################### httpUtils properties #####################
diff --git a/example/example.csv b/austin-web/src/main/resources/example.csv
similarity index 100%
rename from example/example.csv
rename to austin-web/src/main/resources/example.csv
diff --git a/austin-web/src/main/resources/local.properties b/austin-web/src/main/resources/local.properties
new file mode 100644
index 0000000..aa759fa
--- /dev/null
+++ b/austin-web/src/main/resources/local.properties
@@ -0,0 +1,10 @@
+discardMsgIds = []
+deduplicationRule = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
+emailAccount =[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423423@qq.com","pass":"23423432432423423","from":"234@qq.com","starttlsEnable":true,"auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"22222@163.com","pass":"23432423","from":"234324324234@163.com","starttlsEnable":false,"auth":true,"sslEnable":true}}]
+smsAccount = [{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"234234","secretKey":"234324324","smsSdkAppId":"2343242","templateId":"234234","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"23423432","tpl_id":"23423432","supplierId":20,"supplierName":"云片"}}]
+enterpriseWechatAccount = [{"enterprise_wechat_10":{"corpId":"23423423","corpSecret":"-234324234","agentId":1000002,"token":"234234","aesKey":"23423423"}}]
+dingDingRobotAccount = [{"ding_ding_robot_10":{"secret":"234324324324","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b68d081f732343243242343247328b0c3003d164715d2c6c6e56"}}]
+dingDingWorkNoticeAccount =[{"ding_ding_work_notice_10":{"appKey":"23423423","appSecret":"tQpvmkR863dYcuKDVfM23432432432423Nlx_fYLLLlpPJWHvWKbTu","agentId":"1523423423242"}}]
+flowControlRule = {"flow_control_40":1}
+geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}]
+msgTypeSmsConfig = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
diff --git a/docker/redis/redis.conf b/docker/redis/redis.conf
index 15a8946..9e2083b 100644
--- a/docker/redis/redis.conf
+++ b/docker/redis/redis.conf
@@ -1,7 +1,7 @@
protected-mode no
port 6379
timeout 0
-save 900 1 # 900s内至少一次写操作则执行bgsave进行RDB持久化
+save 900 1
save 300 10
save 60 10000
rdbcompression yes
diff --git a/pom.xml b/pom.xml
index 2506f6e..49b1152 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
${target.java.version}
${target.java.version}
2.17.1
- 4.1.0
+ 4.3.0