From c4e556fba109e1e51ded52d719b36c0f59cc2e77 Mon Sep 17 00:00:00 2001
From: "L.Answer"
Date: Thu, 24 Dec 2020 06:12:18 -0800
Subject: [PATCH] feat: dinger 1.0.0
---
pom.xml | 2 +-
.../github/jaemon/dinger/DingerSender.java | 145 +----------------
.../dinger/config/BeanConfiguration.java | 16 +-
.../dinger/config/DingerConfiguration.java | 15 +-
.../dinger/config/DingerThreadPoolConfig.java | 17 +-
.../DingerThreadPoolProperties.java} | 4 +-
.../dinger/constant/DingerConstant.java | 4 -
.../AbstractDingerDefinitionResolver.java | 17 +-
.../{ => core}/AbstractDingerSender.java | 32 ++--
.../dinger/core/DefaultDingerDefinition.java | 2 +-
.../jaemon/dinger/core/DingerConfig.java | 74 +++++++--
.../dinger/core/DingerConfigurerAdapter.java | 2 -
.../jaemon/dinger/core/DingerDefinition.java | 2 +-
.../core/DingerDefinitionGenerator.java | 2 +-
.../DingerDefinitionGeneratorContext.java | 2 +-
.../DingerDefinitionGeneratorFactory.java | 4 +-
.../dinger/core/DingerDefinitionHandler.java | 6 +-
.../dinger/core/DingerDefinitionResolver.java | 8 +-
.../jaemon/dinger/core/DingerHandleProxy.java | 22 +--
.../jaemon/dinger/core/DingerHelper.java | 91 ++++++++---
.../{ => core}/DingerManagerBuilder.java | 4 +-
.../dinger/core/DingerMessageHandler.java | 52 +++----
.../jaemon/dinger/core/DingerRefresh.java | 2 +-
.../jaemon/dinger/{ => core}/DingerRobot.java | 146 +++++++-----------
.../jaemon/dinger/core/DingerSession.java | 11 +-
.../jaemon/dinger/core/MessageTransfer.java | 2 +-
.../{ParamHandle.java => ParamHandler.java} | 10 +-
.../{ResultHandle.java => ResultHandler.java} | 10 +-
.../dinger/core/annatations/AsyncExecute.java | 2 +-
.../dinger/core/annatations/Dinger.java | 6 +-
.../dinger/core/annatations/DingerClose.java | 2 +-
.../core/annatations/DingerConfiguration.java | 6 +-
.../core/annatations/DingerMarkdown.java | 2 +-
.../dinger/core/annatations/DingerScan.java | 2 +-
.../dinger/core/annatations/DingerText.java | 2 +-
.../core/annatations/DingerTokenId.java | 4 +-
.../dinger/core/annatations/Keyword.java | 3 +-
.../dinger/core/annatations/Parameter.java | 2 +-
.../{ => core}/entity/DingerCallback.java | 17 +-
.../dinger/core/entity/DingerProperties.java | 60 +------
.../dinger/core/entity/DingerRequest.java | 122 +++++++++++++++
.../entity/DingerResponse.java} | 28 ++--
.../{entity/enums => core/entity}/Pairs.java | 2 +-
.../core/entity/enums/AsyncExecuteType.java | 2 +-
.../entity/enums/DingerDefinitionType.java | 2 +-
.../entity/enums/DingerResponseCodeEnum.java} | 8 +-
.../dinger/core/entity/enums/DingerType.java | 2 +-
.../core/entity/enums/ExceptionEnum.java | 119 ++++++++++++++
.../core/entity/enums/MessageMainType.java | 2 +-
.../core/entity/enums/MessageSubType.java | 2 +-
.../dinger/core/entity/xml/BeanTag.java | 2 +-
.../dinger/core/entity/xml/BodyTag.java | 2 +-
.../core/entity/xml/ConfigurationTag.java | 2 +-
.../dinger/core/entity/xml/MessageTag.java | 2 +-
.../dinger/core/entity/xml/PhoneTag.java | 2 +-
.../dinger/core/entity/xml/PhonesTag.java | 2 +-
.../dinger/core/entity/xml/TokenId.java | 2 +-
.../jaemon/dinger/core/package-info.java | 2 +-
.../dinger/core/spring/DingerFactoryBean.java | 8 +-
.../core/spring/DingerScannerRegistrar.java | 7 +-
.../dingtalk/DingTalkDefinitionGenerator.java | 2 +-
.../dingtalk/entity/DingTalkMessage.java | 2 +-
.../entity/enums/DingTalkMsgType.java | 2 +-
.../jaemon/dinger/dingtalk/package-info.java | 4 +-
.../dinger/entity/enums/ExceptionEnum.java | 70 ---------
.../dinger/exception/AsyncCallException.java | 2 +-
.../exception/ConfigurationException.java | 2 +-
...tion.java => DingerAnalysisException.java} | 14 +-
.../dinger/exception/DingerException.java | 15 +-
.../InvalidPropertiesFormatException.java | 2 +-
.../dinger/exception/MsgTypeException.java | 2 +-
...java => MultiDingerRegisterException.java} | 17 +-
.../dinger/exception/SendMsgException.java | 2 +-
.../listeners/ApplicationEventTimeTable.java | 81 ----------
.../listeners/DingerListenersProperty.java | 7 +-
.../listeners/DingerXmlPreparedEvent.java | 11 +-
.../dinger/listeners/ExitEventListener.java | 55 +------
.../dinger/listeners/FailedEventListener.java | 80 ----------
.../dinger/listeners/StartEventListener.java | 11 +-
.../listeners/SuccessEventListener.java | 89 -----------
.../jaemon/dinger/listeners/package-info.java | 2 +-
.../dinger/multi/DingerConfigHandler.java | 11 +-
.../MultiDingerAlgorithmInjectRegister.java | 58 ++++---
.../multi/MultiDingerConfigContainer.java | 2 +-
.../dinger/multi/MultiDingerProperty.java | 2 +-
.../dinger/multi/MultiDingerRefresh.java | 2 +-
.../multi/MultiDingerScannerRegistrar.java | 112 ++++++++------
.../multi/algorithm/AlgorithmHandler.java | 2 +-
.../multi/algorithm/DefaultHandler.java | 2 +-
.../dinger/multi/algorithm/DingerHandler.java | 2 +-
.../dinger/multi/algorithm/RandomHandler.java | 2 +-
.../multi/algorithm/RoundRobinHandler.java | 2 +-
.../multi/annotations/EnableMultiDinger.java | 11 +-
.../annotations/MultiDinger.java} | 38 +++--
.../multi/annotations/MultiHandler.java | 6 +-
.../dinger/multi/entity/MultiDinger.java | 2 +-
.../MultiDingerAlgorithmDefinition.java | 18 ++-
.../multi/entity/MultiDingerConfig.java | 2 +-
.../jaemon/dinger/multi/package-info.java | 2 +-
.../jaemon/dinger/support/CustomMessage.java | 4 +-
.../DefaultApplicationEventNotification.java | 70 ---------
.../DefaultDingerExceptionCallback.java | 2 +-
.../support/DingerExceptionCallback.java | 2 +-
.../dinger/support/MarkDownMessage.java | 6 +-
.../support/MonitorEventNotification.java | 107 -------------
.../jaemon/dinger/support/TextMessage.java | 6 +-
.../support/client/DingerHttpClient.java | 2 +-
.../support/client/DingerHttpTemplate.java | 2 +-
.../dinger/support/client/MediaTypeEnum.java | 2 +-
.../sign/DingTalkSignAlgorithm.java | 3 +-
.../sign/DingerSignAlgorithm.java | 4 +-
.../{entity => support/sign}/SignBase.java | 2 +-
.../{entity => support/sign}/SignResult.java | 2 +-
.../github/jaemon/dinger/utils/JVMRandom.java | 2 +-
.../jaemon/dinger/utils/PackageUtils.java | 2 +-
.../jaemon/dinger/utils/RandomUtils.java | 2 +-
.../github/jaemon/dinger/utils/XmlUtils.java | 2 +-
.../wetalk/WeTalkDefinitionGenerator.java | 2 +-
.../jaemon/dinger/wetalk/entity/WeImage.java | 2 +-
.../dinger/wetalk/entity/WeMarkdown.java | 2 +-
.../jaemon/dinger/wetalk/entity/WeNews.java | 2 +-
.../dinger/wetalk/entity/WeTalkMessage.java | 2 +-
.../jaemon/dinger/wetalk/entity/WeText.java | 2 +-
.../wetalk/entity/enums/WeTalkMsgType.java | 2 +-
.../jaemon/dinger/wetalk/package-info.java | 4 +-
src/main/resources/META-INF/spring.factories | 2 -
.../jaemon/dinger/core/OrderDinger.java | 8 +-
.../github/jaemon/dinger/core/UserDinger.java | 8 +-
.../dinger/httpclient/HttpClientTemplate.java | 2 +-
.../dinger/multi/DingerHandlerTest.java | 4 +-
.../dinger/multi/RoundRobinHandlerTest.java | 4 +-
.../handler/UserDingerConfigHandler.java | 12 +-
132 files changed, 850 insertions(+), 1310 deletions(-)
rename src/main/java/com/github/jaemon/dinger/{entity/DkThreadPoolProperties.java => config/DingerThreadPoolProperties.java} (96%)
rename src/main/java/com/github/jaemon/dinger/{ => core}/AbstractDingerSender.java (71%)
rename src/main/java/com/github/jaemon/dinger/{ => core}/DingerManagerBuilder.java (97%)
rename src/main/java/com/github/jaemon/dinger/{ => core}/DingerRobot.java (60%)
rename src/main/java/com/github/jaemon/dinger/core/{ParamHandle.java => ParamHandler.java} (84%)
rename src/main/java/com/github/jaemon/dinger/core/{ResultHandle.java => ResultHandler.java} (84%)
rename src/main/java/com/github/jaemon/dinger/{ => core}/entity/DingerCallback.java (79%)
create mode 100644 src/main/java/com/github/jaemon/dinger/core/entity/DingerRequest.java
rename src/main/java/com/github/jaemon/dinger/{entity/DingerResult.java => core/entity/DingerResponse.java} (67%)
rename src/main/java/com/github/jaemon/dinger/{entity/enums => core/entity}/Pairs.java (94%)
rename src/main/java/com/github/jaemon/dinger/{entity/enums/ResultCode.java => core/entity/enums/DingerResponseCodeEnum.java} (87%)
create mode 100644 src/main/java/com/github/jaemon/dinger/core/entity/enums/ExceptionEnum.java
delete mode 100644 src/main/java/com/github/jaemon/dinger/entity/enums/ExceptionEnum.java
rename src/main/java/com/github/jaemon/dinger/exception/{DingerXmlAnalysisException.java => DingerAnalysisException.java} (64%)
rename src/main/java/com/github/jaemon/dinger/exception/{DingerScanRepeatedException.java => MultiDingerRegisterException.java} (58%)
delete mode 100644 src/main/java/com/github/jaemon/dinger/listeners/ApplicationEventTimeTable.java
delete mode 100644 src/main/java/com/github/jaemon/dinger/listeners/FailedEventListener.java
delete mode 100644 src/main/java/com/github/jaemon/dinger/listeners/SuccessEventListener.java
rename src/main/java/com/github/jaemon/dinger/{exception/DingerConfigRepeatedException.java => multi/annotations/MultiDinger.java} (52%)
delete mode 100644 src/main/java/com/github/jaemon/dinger/support/DefaultApplicationEventNotification.java
delete mode 100644 src/main/java/com/github/jaemon/dinger/support/MonitorEventNotification.java
rename src/main/java/com/github/jaemon/dinger/{ => support}/sign/DingTalkSignAlgorithm.java (92%)
rename src/main/java/com/github/jaemon/dinger/{ => support}/sign/DingerSignAlgorithm.java (95%)
rename src/main/java/com/github/jaemon/dinger/{entity => support/sign}/SignBase.java (95%)
rename src/main/java/com/github/jaemon/dinger/{entity => support/sign}/SignResult.java (97%)
diff --git a/pom.xml b/pom.xml
index 0f0e9ea..c71481c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
- provided
+ test
diff --git a/src/main/java/com/github/jaemon/dinger/DingerSender.java b/src/main/java/com/github/jaemon/dinger/DingerSender.java
index 5e9328f..eced17e 100644
--- a/src/main/java/com/github/jaemon/dinger/DingerSender.java
+++ b/src/main/java/com/github/jaemon/dinger/DingerSender.java
@@ -15,12 +15,10 @@
*/
package com.github.jaemon.dinger;
-import com.github.jaemon.dinger.core.entity.MsgType;
+import com.github.jaemon.dinger.core.entity.DingerRequest;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
import com.github.jaemon.dinger.core.entity.enums.MessageSubType;
-import com.github.jaemon.dinger.entity.DingerResult;
-
-import java.util.List;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
/**
* DingTalk Sender
@@ -36,16 +34,12 @@ public interface DingerSender {
*
* @param messageSubType
* 消息类型{@link MessageSubType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 标题(dingtalk-markdown)
- * @param content
- * 消息内容
+ * @param request
+ * 请求体 {@link DingerRequest}
* @return
* 响应报文
* */
- DingerResult send(MessageSubType messageSubType, String keyword, String title, String content);
+ DingerResponse send(MessageSubType messageSubType, DingerRequest request);
/**
* 发送预警消息到钉钉
@@ -54,134 +48,11 @@ public interface DingerSender {
* Dinger类型 {@link DingerType}
* @param messageSubType
* 消息类型{@link MessageSubType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 标题(dingtalk-markdown)
- * @param content
- * 消息内容
+ * @param request
+ * 请求体 {@link DingerRequest}
* @return
* 响应报文
* */
- DingerResult send(DingerType dingerType, MessageSubType messageSubType, String keyword, String title, String content);
-
+ DingerResponse send(DingerType dingerType, MessageSubType messageSubType, DingerRequest request);
- /**
- * 发送预警消息到钉钉-消息指定艾特人电话信息
- *
- * @param messageSubType
- * 消息类型{@link MessageSubType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 副标题(dingtalk-markdown)
- * @param content
- * 消息内容
- * @param phones
- * 艾特人电话集
- * @return
- * 响应报文
- * */
- DingerResult send(MessageSubType messageSubType, String keyword, String title, String content, List phones);
-
- /**
- * 发送预警消息到钉钉-消息指定艾特人电话信息
- *
- * @param dingerType
- * Dinger类型 {@link DingerType}
- * @param messageSubType
- * 消息类型{@link MessageSubType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 副标题(dingtalk-markdown)
- * @param content
- * 消息内容
- * @param phones
- * 艾特人电话集
- * @return
- * 响应报文
- * */
- DingerResult send(DingerType dingerType, MessageSubType messageSubType, String keyword, String title, String content, List phones);
-
-
- /**
- * 发送预警消息到钉钉-艾特所有人(仅限{@link MessageSubType#TEXT})
- *
- *
- * markdown不支持艾特全部
- *
- *
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 副标题(dingtalk-markdown)
- * @param content
- * 消息内容
- * @return
- * 响应报文
- * */
- DingerResult sendAll(String keyword, String title, String content);
-
- /**
- * 发送预警消息到钉钉-艾特所有人(仅限{@link MessageSubType#TEXT})
- *
- *
- * markdown不支持艾特全部
- *
- *
- * @param dingerType
- * Dinger类型 {@link DingerType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 副标题(dingtalk-markdown)
- * @param content
- * 消息内容
- * @return
- * 响应报文
- * */
- DingerResult sendAll(DingerType dingerType, String keyword, String title, String content);
-
- /**
- * 发送完全自定义消息-对象方式
- *
- *
- * 具体报文体格式参见: https://ding-doc.dingtalk.com/doc#/serverapi3/iydd5h/e9d991e2
- *
- *
- * @param keyword
- * 关键词(方便定位日志)
- * @param message
- * 消息内容
- * @param
- * T extends {@link MsgType}
- * @return
- * 响应报文
- */
- DingerResult send(String keyword, T message);
-
- /**
- * 发送完全自定义消息-json字符串方式
- *
- *
- * 具体报文体格式参见:
- *
- * - DingTalk: https://ding-doc.dingtalk.com/doc#/serverapi3/iydd5h/e9d991e2
- * - WeTalk: https://work.weixin.qq.com/api/doc/90000/90136/91770
- *
- *
- *
- * @param keyword
- * 关键词(方便定位日志)
- * @param dingerType
- * 机器人类型 {@link DingerType}
- * @param message
- * 消息内容
- * @param
- * 消息类型
- * @return
- * 响应报文
- */
- DingerResult send(String keyword, DingerType dingerType, T message);
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/config/BeanConfiguration.java b/src/main/java/com/github/jaemon/dinger/config/BeanConfiguration.java
index e1694e9..24504bc 100644
--- a/src/main/java/com/github/jaemon/dinger/config/BeanConfiguration.java
+++ b/src/main/java/com/github/jaemon/dinger/config/BeanConfiguration.java
@@ -15,9 +15,8 @@
*/
package com.github.jaemon.dinger.config;
-import com.github.jaemon.dinger.sign.DingTalkSignAlgorithm;
-import com.github.jaemon.dinger.sign.DingerSignAlgorithm;
-import com.dingerframework.support.*;
+import com.github.jaemon.dinger.support.sign.DingTalkSignAlgorithm;
+import com.github.jaemon.dinger.support.sign.DingerSignAlgorithm;
import com.github.jaemon.dinger.multi.MultiDingerAlgorithmInjectRegister;
import com.github.jaemon.dinger.support.*;
import com.github.jaemon.dinger.support.client.DingerHttpClient;
@@ -106,17 +105,6 @@ public DingerExceptionCallback dingerExceptionCallback() {
return new DefaultDingerExceptionCallback();
}
- /**
- * 自定义监控事件
- *
- * @return notification instance
- */
- @Bean
- @ConditionalOnMissingBean(MonitorEventNotification.class)
- public MonitorEventNotification monitorEventNotification() {
- return new DefaultApplicationEventNotification();
- }
-
@Bean
public static MultiDingerAlgorithmInjectRegister multiDingerAlgorithmInjectRegister() {
return new MultiDingerAlgorithmInjectRegister();
diff --git a/src/main/java/com/github/jaemon/dinger/config/DingerConfiguration.java b/src/main/java/com/github/jaemon/dinger/config/DingerConfiguration.java
index d0aac00..ce1bece 100644
--- a/src/main/java/com/github/jaemon/dinger/config/DingerConfiguration.java
+++ b/src/main/java/com/github/jaemon/dinger/config/DingerConfiguration.java
@@ -15,12 +15,11 @@
*/
package com.github.jaemon.dinger.config;
-import com.github.jaemon.dinger.DingerManagerBuilder;
-import com.github.jaemon.dinger.DingerRobot;
+import com.github.jaemon.dinger.core.DingerManagerBuilder;
+import com.github.jaemon.dinger.core.DingerRobot;
import com.github.jaemon.dinger.core.DingerConfigurerAdapter;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import com.github.jaemon.dinger.exception.ConfigurationException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -44,24 +43,24 @@ public class DingerConfiguration {
@Bean
@ConditionalOnMissingBean(DingerConfigurerAdapter.class)
- public DingerConfigurerAdapter dingTalkConfigurerAdapter() {
+ public DingerConfigurerAdapter dingerConfigurerAdapter() {
return new DingerConfigurerAdapter();
}
@Bean
- public DingerManagerBuilder dingTalkManagerBuilder() {
+ public DingerManagerBuilder dingerManagerBuilder() {
return new DingerManagerBuilder();
}
@Bean
- public DingerRobot dingerSender(DingerConfigurerAdapter dingTalkConfigurerAdapter, DingerManagerBuilder dingTalkManagerBuilder, ObjectMapper objectMapper){
+ public DingerRobot dingerSender(DingerConfigurerAdapter dingerConfigurerAdapter, DingerManagerBuilder dingerManagerBuilder){
try {
- dingTalkConfigurerAdapter.configure(dingTalkManagerBuilder);
+ dingerConfigurerAdapter.configure(dingerManagerBuilder);
} catch (Exception ex) {
throw new ConfigurationException(ex);
}
- return new DingerRobot(dingerProperties, dingTalkManagerBuilder, objectMapper);
+ return new DingerRobot(dingerProperties, dingerManagerBuilder);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolConfig.java b/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolConfig.java
index 1101a55..bc83aca 100644
--- a/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolConfig.java
+++ b/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolConfig.java
@@ -15,9 +15,8 @@
*/
package com.github.jaemon.dinger.config;
-import com.github.jaemon.dinger.DingerRobot;
+import com.github.jaemon.dinger.core.DingerRobot;
import com.github.jaemon.dinger.constant.DingerConstant;
-import com.github.jaemon.dinger.entity.DkThreadPoolProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -45,23 +44,23 @@
@ConditionalOnBean(DingerRobot.class)
//@Conditional(AsyncCondition.class)
@ConditionalOnMissingBean(name = DingerConstant.DINGER_EXECUTOR)
-@EnableConfigurationProperties({DkThreadPoolProperties.class})
+@EnableConfigurationProperties({DingerThreadPoolProperties.class})
public class DingerThreadPoolConfig {
@Bean(name = DingerConstant.DINGER_EXECUTOR)
- public Executor dingTalkExecutor(DkThreadPoolProperties threadPoolProperties) {
+ public Executor dingTalkExecutor(DingerThreadPoolProperties dingerThreadPoolProperties) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数
- executor.setCorePoolSize(threadPoolProperties.getCoreSize());
+ executor.setCorePoolSize(dingerThreadPoolProperties.getCoreSize());
// 最大线程数
- executor.setMaxPoolSize(threadPoolProperties.getMaxSize());
+ executor.setMaxPoolSize(dingerThreadPoolProperties.getMaxSize());
// 线程最大空闲时间
- executor.setKeepAliveSeconds(threadPoolProperties.getKeepAliveSeconds());
+ executor.setKeepAliveSeconds(dingerThreadPoolProperties.getKeepAliveSeconds());
// 队列大小
- executor.setQueueCapacity(threadPoolProperties.getQueueCapacity());
+ executor.setQueueCapacity(dingerThreadPoolProperties.getQueueCapacity());
// 指定用于新创建的线程名称的前缀
- executor.setThreadNamePrefix(threadPoolProperties.getThreadNamePrefix());
+ executor.setThreadNamePrefix(dingerThreadPoolProperties.getThreadNamePrefix());
// 使用自定义拒绝策略, 直接抛出异常
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
diff --git a/src/main/java/com/github/jaemon/dinger/entity/DkThreadPoolProperties.java b/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolProperties.java
similarity index 96%
rename from src/main/java/com/github/jaemon/dinger/entity/DkThreadPoolProperties.java
rename to src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolProperties.java
index bc02a3f..591aa35 100644
--- a/src/main/java/com/github/jaemon/dinger/entity/DkThreadPoolProperties.java
+++ b/src/main/java/com/github/jaemon/dinger/config/DingerThreadPoolProperties.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger.entity;
+package com.github.jaemon.dinger.config;
import com.github.jaemon.dinger.constant.DingerConstant;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -25,7 +25,7 @@
* @since 1.0
*/
@ConfigurationProperties(prefix = DingerConstant.DINGER_PROPERTIES_PREFIX + "executor-pool")
-public class DkThreadPoolProperties {
+public class DingerThreadPoolProperties {
private static final int DEFAULT_CORE_SIZE = Runtime.getRuntime().availableProcessors() + 1;
/**
* 线程池维护线程的最小数量
diff --git a/src/main/java/com/github/jaemon/dinger/constant/DingerConstant.java b/src/main/java/com/github/jaemon/dinger/constant/DingerConstant.java
index 80f1878..504d129 100644
--- a/src/main/java/com/github/jaemon/dinger/constant/DingerConstant.java
+++ b/src/main/java/com/github/jaemon/dinger/constant/DingerConstant.java
@@ -45,10 +45,6 @@ public interface DingerConstant {
/** 自定义restTemplate名称 */
String DINGER_REST_TEMPLATE = "dingerRestTemplate";
- String SUCCESS_KEYWORD = "_SUCCESS";
- String FAILED_KEYWORD = "_FAILED";
- String EXIT_KEYWORD = "_EXIT";
-
String NEW_LINE = "\r\n";
String SPOT_SEPERATOR = ".";
diff --git a/src/main/java/com/github/jaemon/dinger/core/AbstractDingerDefinitionResolver.java b/src/main/java/com/github/jaemon/dinger/core/AbstractDingerDefinitionResolver.java
index ccd0523..f1e4869 100644
--- a/src/main/java/com/github/jaemon/dinger/core/AbstractDingerDefinitionResolver.java
+++ b/src/main/java/com/github/jaemon/dinger/core/AbstractDingerDefinitionResolver.java
@@ -19,13 +19,10 @@
import com.github.jaemon.dinger.core.annatations.DingerScan;
import com.github.jaemon.dinger.core.entity.enums.DingerDefinitionType;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
import com.github.jaemon.dinger.exception.DingerException;
-import com.github.jaemon.dinger.listeners.ApplicationEventTimeTable;
import com.github.jaemon.dinger.listeners.DingerListenersProperty;
import com.github.jaemon.dinger.utils.PackageUtils;
-import com.github.jaemon.dinger.exception.DingerConfigRepeatedException;
-import com.github.jaemon.dinger.exception.DingerScanRepeatedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
@@ -36,12 +33,14 @@
import java.util.List;
import static com.github.jaemon.dinger.core.AbstractDingerDefinitionResolver.Container.INSTANCE;
+import static com.github.jaemon.dinger.core.entity.enums.ExceptionEnum.DINGER_REPEATED_EXCEPTION;
+import static com.github.jaemon.dinger.core.entity.enums.ExceptionEnum.MULTI_DINGER_SCAN_ERROR;
/**
* AbstractDingerDefinitionResolver
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public abstract class AbstractDingerDefinitionResolver
extends DingerListenersProperty {
@@ -129,7 +128,7 @@ protected List> dingerAnnotationResolver() throws Exception {
DingerScan dingerScan = null;
List> dingerClasses = new ArrayList<>();
// 获取启动类下所有Dinger标注的类信息
- for (Class> primarySource : ApplicationEventTimeTable.primarySources()) {
+ for (Class> primarySource : DingerListenersProperty.primarySources()) {
if (debugEnabled) {
log.debug("ready to analysis primarySource[{}].", primarySource.getName());
}
@@ -139,7 +138,7 @@ protected List> dingerAnnotationResolver() throws Exception {
if (dingerScan == null) {
dingerScan = primarySource.getAnnotation(DingerScan.class);
} else {
- throw new DingerScanRepeatedException();
+ throw new DingerException(MULTI_DINGER_SCAN_ERROR);
}
}
}
@@ -201,7 +200,7 @@ void registerDingerDefinition(
Class extends DingerDefinitionGenerator> dingerDefinitionGeneratorClass =
dingerDefinitionGeneratorMap.get(key);
if (dingerDefinitionGeneratorClass == null) {
- throw new DingerException(key + "无效.", ExceptionEnum.REGISTER_DINGERDEFINITION_ERROR);
+ throw new DingerException(ExceptionEnum.DINGERDEFINITIONTYPE_UNDEFINED_KEY, key);
}
DingerDefinitionGenerator dingerDefinitionGenerator = DingerDefinitionGeneratorFactory.get(
@@ -218,7 +217,7 @@ void registerDingerDefinition(
continue;
}
if (INSTANCE.contains(keyName)) {
- throw new DingerConfigRepeatedException("Dinger[" + keyName + "]消息对象重复定义了.");
+ throw new DingerException(DINGER_REPEATED_EXCEPTION, keyName);
}
// DingerConfig Priority: `@DingerText | @DingerMarkdown | XML` > `@DingerConfiguration` > `***.yml | ***.properties`
diff --git a/src/main/java/com/github/jaemon/dinger/AbstractDingerSender.java b/src/main/java/com/github/jaemon/dinger/core/AbstractDingerSender.java
similarity index 71%
rename from src/main/java/com/github/jaemon/dinger/AbstractDingerSender.java
rename to src/main/java/com/github/jaemon/dinger/core/AbstractDingerSender.java
index b424eda..53d1377 100644
--- a/src/main/java/com/github/jaemon/dinger/AbstractDingerSender.java
+++ b/src/main/java/com/github/jaemon/dinger/core/AbstractDingerSender.java
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger;
+package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.core.DingerHelper;
+import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import com.github.jaemon.dinger.core.entity.enums.MessageSubType;
import com.github.jaemon.dinger.exception.DingerException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.jaemon.dinger.entity.DingerCallback;
+import com.github.jaemon.dinger.core.entity.DingerCallback;
import com.github.jaemon.dinger.support.CustomMessage;
/**
@@ -33,14 +32,12 @@ public abstract class AbstractDingerSender
extends DingerHelper
implements DingerSender {
- DingerProperties dingerProperties;
- DingerManagerBuilder dingTalkManagerBuilder;
- ObjectMapper objectMapper;
+ protected DingerProperties dingerProperties;
+ protected DingerManagerBuilder dingTalkManagerBuilder;
- public AbstractDingerSender(DingerProperties dingerProperties, DingerManagerBuilder dingTalkManagerBuilder, ObjectMapper objectMapper) {
+ public AbstractDingerSender(DingerProperties dingerProperties, DingerManagerBuilder dingTalkManagerBuilder) {
this.dingerProperties = dingerProperties;
this.dingTalkManagerBuilder = dingTalkManagerBuilder;
- this.objectMapper = objectMapper;
}
/**
@@ -51,19 +48,24 @@ public AbstractDingerSender(DingerProperties dingerProperties, DingerManagerBuil
* @return
* 消息生成器
*/
- CustomMessage customMessage(MessageSubType messageSubType) {
+ protected CustomMessage customMessage(MessageSubType messageSubType) {
return messageSubType == MessageSubType.TEXT ? dingTalkManagerBuilder.textMessage : dingTalkManagerBuilder.markDownMessage;
}
/**
* 异常回调
*
- * @param keyword keyword
- * @param message message
- * @param ex ex
+ * @param dingerId
+ * dingerId
+ * @param message
+ * message
+ * @param ex
+ * ex
+ * @param
+ * T
*/
- void exceptionCallback(String dingerId, String keyword, T message, DingerException ex) {
- DingerCallback dkExCallable = new DingerCallback(dingerId, keyword, message, ex);
+ protected void exceptionCallback(String dingerId, T message, DingerException ex) {
+ DingerCallback dkExCallable = new DingerCallback(dingerId, message, ex);
dingTalkManagerBuilder.dingerExceptionCallback.execute(dkExCallable);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/DefaultDingerDefinition.java b/src/main/java/com/github/jaemon/dinger/core/DefaultDingerDefinition.java
index f81d8ba..65fa430 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DefaultDingerDefinition.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DefaultDingerDefinition.java
@@ -25,7 +25,7 @@
* DefaultDingerDefinition
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DefaultDingerDefinition implements DingerDefinition {
private String dingerName;
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerConfig.java b/src/main/java/com/github/jaemon/dinger/core/DingerConfig.java
index d97ce55..9670b64 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerConfig.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerConfig.java
@@ -23,17 +23,17 @@
* DingerConfig
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerConfig {
/**
- * dinger类型 {@link DingerType}
+ * dinger类型 {@link DingerType},不指定默认使用默认的
*/
- private DingerType dingerType = DingerType.DINGTALK;
+ private DingerType dingerType;
private String tokenId;
/** 内部解密秘钥 */
private String decryptKey;
- /** dingtalk签名秘钥 */
+ /** dinger签名秘钥 */
private String secret;
/** 异步执行 */
private Boolean asyncExecute;
@@ -41,48 +41,98 @@ public class DingerConfig {
protected DingerConfig() {
}
- public DingerConfig(String tokenId) {
+ private DingerConfig(String tokenId) {
this.tokenId = tokenId;
}
- public DingerConfig(DingerType dingerType, String tokenId) {
+ private DingerConfig(DingerType dingerType, String tokenId) {
this(tokenId);
this.dingerType = dingerType;
}
- public DingerConfig(String tokenId, String secret) {
+ private DingerConfig(String tokenId, String secret) {
this.tokenId = tokenId;
this.secret = secret;
}
- public DingerConfig(DingerType dingerType, String tokenId, String secret) {
+ private DingerConfig(DingerType dingerType, String tokenId, String secret) {
this(tokenId, secret);
this.dingerType = dingerType;
}
- public DingerConfig(String tokenId, String secret, String decryptKey) {
+ private DingerConfig(String tokenId, boolean async) {
+ this.tokenId = tokenId;
+ this.asyncExecute = async;
+ }
+
+ private DingerConfig(DingerType dingerType, String tokenId, boolean async) {
+ this(tokenId, async);
+ this.dingerType = dingerType;
+ }
+
+ private DingerConfig(String tokenId, String secret, String decryptKey) {
this.tokenId = tokenId;
this.decryptKey = decryptKey;
this.secret = secret;
}
- public DingerConfig(DingerType dingerType, String tokenId, String secret, String decryptKey) {
+ private DingerConfig(DingerType dingerType, String tokenId, String secret, String decryptKey) {
this(tokenId, secret, decryptKey);
this.dingerType = dingerType;
}
- public DingerConfig(String tokenId, String secret, String decryptKey, boolean asyncExecute) {
+ private DingerConfig(String tokenId, String secret, String decryptKey, boolean asyncExecute) {
this.tokenId = tokenId;
this.decryptKey = decryptKey;
this.secret = secret;
this.asyncExecute = asyncExecute;
}
- public DingerConfig(DingerType dingerType, String tokenId, String secret, String decryptKey, boolean asyncExecute) {
+ private DingerConfig(DingerType dingerType, String tokenId, String secret, String decryptKey, boolean asyncExecute) {
this(tokenId, secret, decryptKey, asyncExecute);
this.dingerType = dingerType;
}
+ public static DingerConfig instance(String tokenId) {
+ return new DingerConfig(tokenId);
+ }
+
+ public static DingerConfig instance(DingerType dingerType, String tokenId) {
+ return new DingerConfig(dingerType, tokenId);
+ }
+
+ public static DingerConfig instance(String tokenId, String secret) {
+ return new DingerConfig(tokenId, secret);
+ }
+
+ public static DingerConfig instance(DingerType dingerType, String tokenId, String secret) {
+ return new DingerConfig(dingerType, tokenId, secret);
+ }
+
+ public static DingerConfig instance(String tokenId, boolean asyncExecute) {
+ return new DingerConfig(tokenId, asyncExecute);
+ }
+
+ public static DingerConfig instance(DingerType dingerType, String tokenId, boolean asyncExecute) {
+ return new DingerConfig(dingerType, tokenId, asyncExecute);
+ }
+
+ public static DingerConfig instance(String tokenId, String secret, String decryptKey) {
+ return new DingerConfig(tokenId, secret, decryptKey);
+ }
+
+ public static DingerConfig instance(DingerType dingerType, String tokenId, String secret, String decryptKey) {
+ return new DingerConfig(dingerType, tokenId, secret, decryptKey);
+ }
+
+ public static DingerConfig instance(String tokenId, String secret, String decryptKey, boolean asyncExecute) {
+ return new DingerConfig(tokenId, secret, decryptKey, asyncExecute);
+ }
+
+ public static DingerConfig instance(DingerType dingerType, String tokenId, String secret, String decryptKey, boolean asyncExecute) {
+ return new DingerConfig(dingerType, tokenId, secret, decryptKey, asyncExecute);
+ }
+
/**
* do check dinger config
*/
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerConfigurerAdapter.java b/src/main/java/com/github/jaemon/dinger/core/DingerConfigurerAdapter.java
index ba4b3b8..b8fe7c6 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerConfigurerAdapter.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerConfigurerAdapter.java
@@ -15,8 +15,6 @@
*/
package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.DingerManagerBuilder;
-
/**
* DingTalk Configurer Adapter
*
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinition.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinition.java
index 77ca374..62237ec 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinition.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinition.java
@@ -25,7 +25,7 @@
* DingerDefinition
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public interface DingerDefinition {
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGenerator.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGenerator.java
index a2e3f26..4b424c2 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGenerator.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGenerator.java
@@ -20,7 +20,7 @@
* Diner消息体定义生成
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public abstract class DingerDefinitionGenerator {
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorContext.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorContext.java
index 68ab499..e85352a 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorContext.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorContext.java
@@ -19,7 +19,7 @@
* DingerDefinitionGeneratorContext
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingerDefinitionGeneratorContext {
private String keyName;
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorFactory.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorFactory.java
index 18245ed..407ee00 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorFactory.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionGeneratorFactory.java
@@ -20,13 +20,13 @@
import java.util.HashMap;
import java.util.Map;
-import static com.github.jaemon.dinger.entity.enums.ExceptionEnum.DINGERDEFINITION_ERROR;
+import static com.github.jaemon.dinger.core.entity.enums.ExceptionEnum.DINGERDEFINITION_ERROR;
/**
* Dinger Definition工厂类
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingerDefinitionGeneratorFactory {
/** dingerDefinition生成器 */
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionHandler.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionHandler.java
index 186dcb6..f40a1fc 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionHandler.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionHandler.java
@@ -16,11 +16,9 @@
package com.github.jaemon.dinger.core;
import com.github.jaemon.dinger.core.annatations.DingerTokenId;
-import com.dingerframework.core.entity.enums.*;
import com.github.jaemon.dinger.core.annatations.DingerMarkdown;
import com.github.jaemon.dinger.core.annatations.DingerText;
import com.github.jaemon.dinger.core.entity.MsgType;
-import com.dingerframework.core.entity.xml.*;
import com.github.jaemon.dinger.core.entity.enums.*;
import com.github.jaemon.dinger.core.entity.xml.*;
import com.github.jaemon.dinger.exception.DingerException;
@@ -33,13 +31,13 @@
import java.util.Optional;
import java.util.stream.Collectors;
-import static com.github.jaemon.dinger.entity.enums.ExceptionEnum.DINGERDEFINITIONTYPE_ERROR;
+import static com.github.jaemon.dinger.core.entity.enums.ExceptionEnum.DINGERDEFINITIONTYPE_ERROR;
/**
* DefinitionGenerator
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingerDefinitionHandler {
private static final Logger log = LoggerFactory.getLogger(DingerDefinitionHandler.class);
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionResolver.java b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionResolver.java
index 6bb1249..e5afa59 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionResolver.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerDefinitionResolver.java
@@ -40,13 +40,13 @@
import java.util.*;
import static com.github.jaemon.dinger.constant.DingerConstant.SPOT_SEPERATOR;
-import static com.github.jaemon.dinger.entity.enums.ExceptionEnum.DINER_XML_ANALYSIS_EXCEPTION;
+import static com.github.jaemon.dinger.core.entity.enums.ExceptionEnum.*;
/**
* DingerDefinitionResolver
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerDefinitionResolver extends AbstractDingerDefinitionResolver {
private static final Logger log = LoggerFactory.getLogger(DingerDefinitionResolver.class);
@@ -99,7 +99,7 @@ void analysisDingerXml(Resource[] resources) throws Exception {
String namespace = dingerBean.getNamespace();
Class> dingerClass = Class.forName(namespace);
if (dingerClass == null) {
- throw new DingerException(DINER_XML_ANALYSIS_EXCEPTION);
+ throw new DingerException(namespace, DINER_XML_NAMESPACE_INVALID);
}
DingerConfig dingerConfiguration = dingerConfiguration(dingerClass);
@@ -109,7 +109,7 @@ void analysisDingerXml(Resource[] resources) throws Exception {
String dingerName = namespace + SPOT_SEPERATOR + message.getIdentityId();
String messageSubType = message.getDingerType();
if (!MessageSubType.contains(messageSubType)) {
- throw new DingerException(dingerName + "中定义了无效的messageType" + messageSubType, DINER_XML_ANALYSIS_EXCEPTION);
+ throw new DingerException(dingerName + "-" + messageSubType, DINER_XML_MSGTYPE_INVALID);
}
String dingerDefinitionKey = MessageMainType.XML + SPOT_SEPERATOR + message.getDingerType();
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerHandleProxy.java b/src/main/java/com/github/jaemon/dinger/core/DingerHandleProxy.java
index 3470def..f2225dc 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerHandleProxy.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerHandleProxy.java
@@ -15,12 +15,11 @@
*/
package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.core.annatations.DingerClose;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import com.github.jaemon.dinger.core.entity.MsgType;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
-import com.github.jaemon.dinger.entity.DingerResult;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,14 +33,14 @@
* Dinger Handle Proxy
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerHandleProxy extends DingerMessageHandler implements InvocationHandler {
private static final Logger log = LoggerFactory.getLogger(DingerHandleProxy.class);
private static final String DEFAULT_STRING_METHOD = "java.lang.Object.toString";
- public DingerHandleProxy(DingerSender dingerSender, DingerProperties dingerProperties) {
- this.dingerSender = dingerSender;
+ public DingerHandleProxy(DingerRobot dingerRobot, DingerProperties dingerProperties) {
+ this.dingerRobot = dingerRobot;
this.dingerProperties = dingerProperties;
}
@@ -68,7 +67,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
try {
// method params map
- Map params = paramsHandle(method.getParameters(), args);
+ Map params = paramsHandler(method.getParameters(), args);
DingerType useDinger = dingerType(method);
DingerDefinition dingerDefinition = dingerDefinition(
@@ -80,17 +79,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
MsgType message = transfer(dingerDefinition, params);
- // when keyword is null, use methodName + timestamps
- String keyword = params.getOrDefault(
- KEYWORD,
- keyName + CONNECTOR + System.currentTimeMillis()
- ).toString();
- DingerResult dingerResult = dingerSender.send(
- keyword, message
- );
+ DingerResponse dingerResponse = dingerRobot.send(message);
// return...
- return resultHandle(method.getReturnType(), dingerResult);
+ return resultHandler(method.getReturnType(), dingerResponse);
} finally {
DingerHelper.clearDinger();
}
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerHelper.java b/src/main/java/com/github/jaemon/dinger/core/DingerHelper.java
index e87c70d..0c4ad59 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerHelper.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerHelper.java
@@ -21,7 +21,7 @@
* DingerHelper
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public abstract class DingerHelper {
protected static final ThreadLocal LOCAL_DINGER = new ThreadLocal<>();
@@ -31,18 +31,22 @@ public abstract class DingerHelper {
*
* @param dingerConfig
* dingerConfig {@link DingerConfig}
+ * @return
+ * dingerConfig {@link DingerConfig}
*/
- public static void assignDinger(DingerConfig dingerConfig) {
+ public static DingerConfig assignDinger(DingerConfig dingerConfig) {
dingerConfig.check();
if (dingerConfig.checkEmpty()) {
// use default
- return;
+ return null;
}
setLocalDinger(dingerConfig);
+
+ return dingerConfig;
}
/**
- * assignDinger for dingtalk
+ * assignDinger for dingtalk(使用原有dingerType)
*
* @param tokenId
* dingtalk tokenId
@@ -50,7 +54,8 @@ public static void assignDinger(DingerConfig dingerConfig) {
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(String tokenId) {
- return assignDinger(tokenId, false);
+ DingerConfig dingerConfig = DingerConfig.instance(tokenId);
+ return assignDinger(dingerConfig);
}
/**
@@ -64,7 +69,8 @@ public static DingerConfig assignDinger(String tokenId) {
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(DingerType dingerType, String tokenId) {
- return assignDinger(dingerType, tokenId, false);
+ DingerConfig dingerConfig = DingerConfig.instance(dingerType, tokenId);
+ return assignDinger(dingerConfig);
}
/**
@@ -78,7 +84,8 @@ public static DingerConfig assignDinger(DingerType dingerType, String tokenId) {
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(String tokenId, boolean asyncExecute) {
- return assignDinger(tokenId, null, asyncExecute);
+ DingerConfig dingerConfig = DingerConfig.instance(tokenId, asyncExecute);
+ return assignDinger(dingerConfig);
}
/**
@@ -94,7 +101,8 @@ public static DingerConfig assignDinger(String tokenId, boolean asyncExecute) {
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(DingerType dingerType, String tokenId, boolean asyncExecute) {
- return assignDinger(dingerType, tokenId, null, asyncExecute);
+ DingerConfig dingerConfig = DingerConfig.instance(dingerType, tokenId, asyncExecute);
+ return assignDinger(dingerConfig);
}
/**
@@ -109,7 +117,26 @@ public static DingerConfig assignDinger(DingerType dingerType, String tokenId, b
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(String tokenId, String secret) {
- return assignDinger(DingerType.DINGTALK, tokenId, null, secret, false);
+ DingerConfig dingerConfig = DingerConfig.instance(tokenId, secret);
+ return assignDinger(dingerConfig);
+ }
+
+ /**
+ * assignDinger for dingtalk
+ *
+ * @param dingerType
+ * dingerType
+ * @param tokenId
+ * dingtalk tokenId
+ * @param secret
+ * dingtalk secret
+ *
+ * @return
+ * dingerConfig {@link DingerConfig}
+ */
+ public static DingerConfig assignDinger(DingerType dingerType, String tokenId, String secret) {
+ DingerConfig dingerConfig = DingerConfig.instance(dingerType, tokenId, secret);
+ return assignDinger(dingerConfig);
}
/**
@@ -125,7 +152,9 @@ public static DingerConfig assignDinger(String tokenId, String secret) {
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(String tokenId, String decryptKey, boolean asyncExecute) {
- return assignDinger(DingerType.DINGTALK, tokenId, decryptKey, null, asyncExecute);
+ DingerConfig dingerConfig = DingerConfig.instance(tokenId, asyncExecute);
+ dingerConfig.setDecryptKey(decryptKey);
+ return assignDinger(dingerConfig);
}
/**
@@ -143,7 +172,10 @@ public static DingerConfig assignDinger(String tokenId, String decryptKey, boole
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(DingerType dingerType, String tokenId, String decryptKey, boolean asyncExecute) {
- return assignDinger(dingerType, tokenId, decryptKey, null, asyncExecute);
+ DingerConfig dingerConfig = DingerConfig.instance(dingerType, tokenId);
+ dingerConfig.setDecryptKey(decryptKey);
+ dingerConfig.setAsyncExecute(asyncExecute);
+ return assignDinger(dingerConfig);
}
/**
@@ -159,7 +191,27 @@ public static DingerConfig assignDinger(DingerType dingerType, String tokenId, S
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(String tokenId, String decryptKey, String secret) {
- return assignDinger(DingerType.DINGTALK, tokenId, decryptKey, secret, false);
+ DingerConfig dingerConfig = DingerConfig.instance(tokenId, secret, decryptKey);
+ return assignDinger(dingerConfig);
+ }
+
+ /**
+ * assignDinger for dingtalk
+ *
+ * @param dingerType
+ * dingerType
+ * @param tokenId
+ * dingtalk tokenId
+ * @param decryptKey
+ * tokenId decrypt key
+ * @param secret
+ * dingtalk secret
+ * @return
+ * dingerConfig {@link DingerConfig}
+ */
+ public static DingerConfig assignDinger(DingerType dingerType, String tokenId, String decryptKey, String secret) {
+ DingerConfig dingerConfig = DingerConfig.instance(dingerType, tokenId, secret, decryptKey);
+ return assignDinger(dingerConfig);
}
/**
@@ -179,17 +231,10 @@ public static DingerConfig assignDinger(String tokenId, String decryptKey, Strin
* dingerConfig {@link DingerConfig}
*/
public static DingerConfig assignDinger(DingerType dingerType, String tokenId, String decryptKey, String secret, boolean asyncExecute) {
- DingerConfig dingerConfig = new DingerConfig();
- if (dingerType != null) {
- dingerConfig.setDingerType(dingerType);
- }
- dingerConfig.setTokenId(tokenId);
- dingerConfig.setDecryptKey(decryptKey);
- dingerConfig.setSecret(secret);
- dingerConfig.setAsyncExecute(asyncExecute);
-
- assignDinger(dingerConfig);
- return dingerConfig;
+ DingerConfig dingerConfig = DingerConfig.instance(
+ dingerType, tokenId, decryptKey, secret, asyncExecute
+ );
+ return assignDinger(dingerConfig);
}
diff --git a/src/main/java/com/github/jaemon/dinger/DingerManagerBuilder.java b/src/main/java/com/github/jaemon/dinger/core/DingerManagerBuilder.java
similarity index 97%
rename from src/main/java/com/github/jaemon/dinger/DingerManagerBuilder.java
rename to src/main/java/com/github/jaemon/dinger/core/DingerManagerBuilder.java
index 531a017..080aa87 100644
--- a/src/main/java/com/github/jaemon/dinger/DingerManagerBuilder.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerManagerBuilder.java
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger;
+package com.github.jaemon.dinger.core;
import com.github.jaemon.dinger.core.entity.enums.MessageSubType;
-import com.github.jaemon.dinger.sign.DingerSignAlgorithm;
+import com.github.jaemon.dinger.support.sign.DingerSignAlgorithm;
import com.github.jaemon.dinger.support.DingerExceptionCallback;
import com.github.jaemon.dinger.support.CustomMessage;
import com.github.jaemon.dinger.support.DingerAsyncCallback;
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerMessageHandler.java b/src/main/java/com/github/jaemon/dinger/core/DingerMessageHandler.java
index 3f33aa9..fb10d37 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerMessageHandler.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerMessageHandler.java
@@ -15,13 +15,11 @@
*/
package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.core.annatations.Dinger;
-import com.github.jaemon.dinger.core.annatations.Keyword;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import com.github.jaemon.dinger.core.entity.MsgType;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
-import com.github.jaemon.dinger.entity.DingerResult;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
import com.github.jaemon.dinger.listeners.DingerXmlPreparedEvent;
import com.github.jaemon.dinger.multi.MultiDingerConfigContainer;
import com.github.jaemon.dinger.multi.MultiDingerProperty;
@@ -45,47 +43,35 @@
* DingerMessageHandler
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerMessageHandler
extends MultiDingerProperty
- implements ParamHandle, MessageTransfer, ResultHandle {
+ implements ParamHandler, MessageTransfer, ResultHandler {
private static final Logger log = LoggerFactory.getLogger(DingerMessageHandler.class);
- protected static final String KEYWORD = "DINGTALK_DINGER_METHOD_SENDER_KEYWORD";
- protected static final String CONNECTOR = "_";
- protected DingerSender dingerSender;
+ protected DingerRobot dingerRobot;
protected DingerProperties dingerProperties;
@Override
- public Map paramsHandle(Parameter[] parameters, Object[] values) {
+ public Map paramsHandler(Parameter[] parameters, Object[] values) {
Map params = new HashMap<>();
if (parameters.length == 0) {
return params;
}
- int keyWordIndex = -1;
- String keywordValue = null;
for (int i = 0; i < parameters.length; i++) {
Parameter parameter = parameters[i];
String paramName = parameter.getName();
com.github.jaemon.dinger.core.annatations.Parameter[] panno =
parameter.getDeclaredAnnotationsByType(com.github.jaemon.dinger.core.annatations.Parameter.class);
- Keyword[] kanno = parameter.getDeclaredAnnotationsByType(Keyword.class);
+// Keyword[] kanno = parameter.getDeclaredAnnotationsByType(Keyword.class);
if (panno != null && panno.length > 0) {
paramName = panno[0].value();
- } else if (kanno != null && kanno.length > 0) {
- keyWordIndex = i;
- keywordValue = values[i].toString();
- continue;
}
params.put(paramName, values[i]);
}
- if (keyWordIndex != -1) {
- params.put(KEYWORD, keywordValue);
- }
-
return params;
}
@@ -99,12 +85,12 @@ public MsgType transfer(DingerDefinition dingerDefinition, Map p
@Override
- public Object resultHandle(Class> resultType, DingerResult dingerResult) {
+ public Object resultHandler(Class> resultType, DingerResponse dingerResponse) {
String name = resultType.getName();
if (String.class.getName().equals(name)) {
- return Optional.ofNullable(dingerResult).map(e -> e.getData()).orElse(null);
- } else if (DingerResult.class.getName().equals(name)) {
- return dingerResult;
+ return Optional.ofNullable(dingerResponse).map(e -> e.getData()).orElse(null);
+ } else if (DingerResponse.class.getName().equals(name)) {
+ return dingerResponse;
}
return null;
}
@@ -160,20 +146,24 @@ DingerType dingerType(Method method) {
/**
* 获取Dinger定义
*
- * @param defaultDinger
- * 代理方法默认Dinger
+ *
+ * 优先级: local(dinger为空使用默认 {@link DingerMessageHandler#dingerType}) > multi > default
+ *
+ *
+ * @param useDinger
+ * 代理方法使用的Dinger
* @param keyName
* keyName
* @return
* dingerDefinition {@link DingerDefinition}
*/
- DingerDefinition dingerDefinition(DingerType defaultDinger, String keyName) {
+ DingerDefinition dingerDefinition(DingerType useDinger, String keyName) {
DingerDefinition dingerDefinition;
DingerConfig localDinger = DingerHelper.getLocalDinger();
// 优先使用用户设定 dingerConfig
if (localDinger == null) {
- keyName = defaultDinger + SPOT_SEPERATOR + keyName;
+ keyName = useDinger + SPOT_SEPERATOR + keyName;
dingerDefinition = DingerXmlPreparedEvent
.Container.INSTANCE.get(keyName);
@@ -208,7 +198,11 @@ DingerDefinition dingerDefinition(DingerType defaultDinger, String keyName) {
}
} else {
- keyName = localDinger.getDingerType() + SPOT_SEPERATOR + keyName;
+ DingerType dingerType = localDinger.getDingerType();
+ if (dingerType == null) {
+ dingerType = useDinger;
+ }
+ keyName = dingerType + SPOT_SEPERATOR + keyName;
dingerDefinition = DingerXmlPreparedEvent
.Container.INSTANCE.get(keyName);
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerRefresh.java b/src/main/java/com/github/jaemon/dinger/core/DingerRefresh.java
index 618ed7b..9e1a756 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerRefresh.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerRefresh.java
@@ -19,7 +19,7 @@
* DingerRefresh
*
* @author Jaemon
- * @since 3.0
+ * @since 1.0
*/
public class DingerRefresh {
diff --git a/src/main/java/com/github/jaemon/dinger/DingerRobot.java b/src/main/java/com/github/jaemon/dinger/core/DingerRobot.java
similarity index 60%
rename from src/main/java/com/github/jaemon/dinger/DingerRobot.java
rename to src/main/java/com/github/jaemon/dinger/core/DingerRobot.java
index 80757f5..6e5cbed 100644
--- a/src/main/java/com/github/jaemon/dinger/DingerRobot.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerRobot.java
@@ -13,18 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger;
+package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.entity.DingerResult;
-import com.github.jaemon.dinger.entity.SignBase;
+import com.github.jaemon.dinger.core.entity.DingerRequest;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
+import com.github.jaemon.dinger.support.sign.SignBase;
import com.github.jaemon.dinger.support.client.MediaTypeEnum;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.jaemon.dinger.core.DingerConfig;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
import com.github.jaemon.dinger.core.entity.enums.MessageSubType;
-import com.github.jaemon.dinger.entity.enums.ResultCode;
+import com.github.jaemon.dinger.core.entity.enums.DingerResponseCodeEnum;
import com.github.jaemon.dinger.core.entity.MsgType;
import com.github.jaemon.dinger.exception.AsyncCallException;
import com.github.jaemon.dinger.exception.SendMsgException;
@@ -45,54 +43,65 @@
*/
public class DingerRobot extends AbstractDingerSender {
- public DingerRobot(DingerProperties dingerProperties, DingerManagerBuilder dingTalkManagerBuilder, ObjectMapper objectMapper) {
- super(dingerProperties, dingTalkManagerBuilder, objectMapper);
+ public DingerRobot(DingerProperties dingerProperties, DingerManagerBuilder dingTalkManagerBuilder) {
+ super(dingerProperties, dingTalkManagerBuilder);
}
@Override
- public DingerResult send(MessageSubType messageSubType, String keyword, String title, String content) {
- return send(dingerProperties.getDefaultDinger(), messageSubType, keyword, title, content);
+ public DingerResponse send(MessageSubType messageSubType, DingerRequest request) {
+ return send(dingerProperties.getDefaultDinger(), messageSubType, request.getTitle(), request.getContent(), request.getPhones(), request.isAtAll());
}
@Override
- public DingerResult send(DingerType dingerType, MessageSubType messageSubType, String keyword, String title, String content) {
- return send(dingerType, messageSubType, keyword, title, content, null, false);
+ public DingerResponse send(DingerType dingerType, MessageSubType messageSubType, DingerRequest request) {
+ return send(dingerType, messageSubType, request.getTitle(), request.getContent(), request.getPhones(), request.isAtAll());
}
- @Override
- public DingerResult send(MessageSubType messageSubType, String keyword, String title, String content, List phones) {
- return send(dingerProperties.getDefaultDinger(), messageSubType, keyword, title, content, phones);
- }
-
-
- @Override
- public DingerResult send(DingerType dingerType, MessageSubType messageSubType, String keyword, String title, String content, List phones) {
- return send(dingerType, messageSubType, keyword, title, content, phones, false);
- }
-
- @Override
- public DingerResult sendAll(String keyword, String title, String content) {
- return sendAll(dingerProperties.getDefaultDinger(), keyword, title, content);
- }
+ /**
+ * 发送预警消息到钉钉-艾特所有人
+ *
+ *
+ * markdown不支持艾特全部
+ *
+ *
+ * @param dingerType
+ * Dinger类型 {@link DingerType}
+ * @param messageSubType
+ * 消息类型{@link MessageSubType}
+ * @param title
+ * 副标题
+ * @param content
+ * 消息内容
+ * @param phones
+ * 艾特成员
+ * @param atAll
+ * 是否艾特所有人
+ * @return
+ * 响应报文
+ * */
+ private DingerResponse send(DingerType dingerType, MessageSubType messageSubType, String title, String content, List phones, boolean atAll) {
+ CustomMessage customMessage = customMessage(messageSubType);
+ String msgContent = customMessage.message(
+ dingerProperties.getProjectId(), title, content, phones
+ );
+ MsgType msgType = messageSubType.msgType(
+ dingerType, msgContent, title, phones, atAll
+ );
- @Override
- public DingerResult sendAll(DingerType dingerType, String keyword, String title, String content) {
- return send(dingerType, MessageSubType.MARKDOWN, keyword, title, content, null, true);
+ return send(msgType);
}
-
- @Override
- public DingerResult send(String keyword, T message) {
- try {
- return send(keyword, message.getDingerType(), objectMapper.writeValueAsString(message));
- } catch (JsonProcessingException e) {
- return DingerResult.failed(ResultCode.MESSAGE_PROCESSING_FAILED, dingTalkManagerBuilder.dingerIdGenerator.dingerId());
- }
- }
-
- @Override
- public DingerResult send(String keyword, DingerType dingerType, T message) {
+ /**
+ * @param message
+ * 消息内容
+ * @param
+ * T
+ * @return
+ * 响应内容 {@link DingerResponse}
+ */
+ protected DingerResponse send(T message) {
+ DingerType dingerType = message.getDingerType();
String dkid = dingTalkManagerBuilder.dingerIdGenerator.dingerId();
Map dingers = dingerProperties.getDingers();
if (!
@@ -101,7 +110,7 @@ public DingerResult send(String keyword, DingerType dingerType, T message) {
dingers.containsKey(dingerType)
)
) {
- return DingerResult.failed(ResultCode.DINGER_DISABLED, dkid);
+ return DingerResponse.failed(DingerResponseCodeEnum.DINGER_DISABLED, dkid);
}
DingerConfig localDinger = getLocalDinger();
@@ -139,59 +148,20 @@ public DingerResult send(String keyword, DingerType dingerType, T message) {
);
dingTalkManagerBuilder.dingerAsyncCallback.execute(dkid, result);
} catch (Exception e) {
- exceptionCallback(dkid, keyword, message, new AsyncCallException(e));
+ exceptionCallback(dkid, message, new AsyncCallException(e));
}
});
- return DingerResult.success(dkid, dkid);
+ return DingerResponse.success(dkid, dkid);
}
String response = dingTalkManagerBuilder.dingerHttpClient.post(
webhook.toString(), headers, message, MediaTypeEnum.JSON
);
- return DingerResult.success(dkid, response);
+ return DingerResponse.success(dkid, response);
} catch (Exception e) {
- exceptionCallback(dkid, keyword, message, new SendMsgException(e));
- return DingerResult.failed(ResultCode.SEND_MESSAGE_FAILED, dkid);
+ exceptionCallback(dkid, message, new SendMsgException(e));
+ return DingerResponse.failed(DingerResponseCodeEnum.SEND_MESSAGE_FAILED, dkid);
}
}
-
- /**
- * 发送预警消息到钉钉-艾特所有人
- *
- *
- * markdown不支持艾特全部
- *
- *
- * @param dingerType
- * Dinger类型 {@link DingerType}
- * @param messageSubType
- * 消息类型{@link MessageSubType}
- * @param keyword
- * 关键词(方便定位日志)
- * @param title
- * 副标题
- * @param content
- * 消息内容
- * @param phones
- * 艾特成员
- * @param atAll
- * 是否艾特所有人
- * @return
- * 响应报文
- * */
- private DingerResult send(DingerType dingerType, MessageSubType messageSubType, String keyword, String title, String content, List phones, boolean atAll) {
- CustomMessage customMessage = customMessage(messageSubType);
- String msgContent = customMessage.message(
- dingerProperties.getProjectId(), title, keyword, content, phones
- );
-
- MsgType msgType = messageSubType.msgType(
- dingerType, msgContent, title, phones, atAll
- );
-
- return send(keyword, msgType);
-
- }
-
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/DingerSession.java b/src/main/java/com/github/jaemon/dinger/core/DingerSession.java
index 400bb82..9cad719 100644
--- a/src/main/java/com/github/jaemon/dinger/core/DingerSession.java
+++ b/src/main/java/com/github/jaemon/dinger/core/DingerSession.java
@@ -15,7 +15,6 @@
*/
package com.github.jaemon.dinger.core;
-import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import java.lang.reflect.Proxy;
@@ -24,14 +23,14 @@
* DingerSession
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerSession {
- private DingerSender dingerSender;
+ private DingerRobot dingerRobot;
private DingerProperties dingerProperties;
- public DingerSession(DingerSender dingerSender, DingerProperties dingerProperties) {
- this.dingerSender = dingerSender;
+ public DingerSession(DingerRobot dingerRobot, DingerProperties dingerProperties) {
+ this.dingerRobot = dingerRobot;
this.dingerProperties = dingerProperties;
}
@@ -40,7 +39,7 @@ public T getDinger(Class type) {
// bugfix gitee#I29N15
Thread.currentThread().getContextClassLoader(),
new Class[]{type},
- new DingerHandleProxy(dingerSender, dingerProperties)
+ new DingerHandleProxy(dingerRobot, dingerProperties)
);
}
diff --git a/src/main/java/com/github/jaemon/dinger/core/MessageTransfer.java b/src/main/java/com/github/jaemon/dinger/core/MessageTransfer.java
index 966a594..58a88da 100644
--- a/src/main/java/com/github/jaemon/dinger/core/MessageTransfer.java
+++ b/src/main/java/com/github/jaemon/dinger/core/MessageTransfer.java
@@ -23,7 +23,7 @@
* MessageTransfer
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public interface MessageTransfer {
diff --git a/src/main/java/com/github/jaemon/dinger/core/ParamHandle.java b/src/main/java/com/github/jaemon/dinger/core/ParamHandler.java
similarity index 84%
rename from src/main/java/com/github/jaemon/dinger/core/ParamHandle.java
rename to src/main/java/com/github/jaemon/dinger/core/ParamHandler.java
index 6c7aade..373b129 100644
--- a/src/main/java/com/github/jaemon/dinger/core/ParamHandle.java
+++ b/src/main/java/com/github/jaemon/dinger/core/ParamHandler.java
@@ -19,20 +19,20 @@
import java.util.Map;
/**
- * ParamHandle
+ * ParamHandler
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
-public interface ParamHandle {
+public interface ParamHandler {
/**
- * paramsHandle
+ * paramsHandler
*
* @param parameters parameters
* @param values values
* @return params map
*/
- Map paramsHandle(Parameter[] parameters, Object[] values);
+ Map paramsHandler(Parameter[] parameters, Object[] values);
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/ResultHandle.java b/src/main/java/com/github/jaemon/dinger/core/ResultHandler.java
similarity index 84%
rename from src/main/java/com/github/jaemon/dinger/core/ResultHandle.java
rename to src/main/java/com/github/jaemon/dinger/core/ResultHandler.java
index eeeb25a..24fa109 100644
--- a/src/main/java/com/github/jaemon/dinger/core/ResultHandle.java
+++ b/src/main/java/com/github/jaemon/dinger/core/ResultHandler.java
@@ -16,18 +16,18 @@
package com.github.jaemon.dinger.core;
/**
- * ResultHandle
+ * ResultHandler
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
-public interface ResultHandle {
+public interface ResultHandler {
/**
- * resultHandle
+ * resultHandler
*
* @param resultType resultType
* @param t T
* @return object
*/
- Object resultHandle(Class> resultType, T t);
+ Object resultHandler(Class> resultType, T t);
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/AsyncExecute.java b/src/main/java/com/github/jaemon/dinger/core/annatations/AsyncExecute.java
index bcdf392..6f1e75d 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/AsyncExecute.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/AsyncExecute.java
@@ -21,7 +21,7 @@
* AsyncExecute(xml and annotation)
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/Dinger.java b/src/main/java/com/github/jaemon/dinger/core/annatations/Dinger.java
index 43cd86c..bb582d5 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/Dinger.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/Dinger.java
@@ -20,13 +20,13 @@
import java.lang.annotation.*;
/**
- * Dinger
+ * 指定当前 ***Dinger
使用的 Dinger 类型
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD})
+@Target(ElementType.TYPE)
@Documented
public @interface Dinger {
/**
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerClose.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerClose.java
index 6381995..f1fb66a 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerClose.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerClose.java
@@ -21,7 +21,7 @@
* DingerClose
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerConfiguration.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerConfiguration.java
index 73d7ee7..d1b201c 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerConfiguration.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerConfiguration.java
@@ -21,14 +21,14 @@
* DingerConfiguration(xml and annotation)
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
public @interface DingerConfiguration {
/**
- * dingtalk tokenId
+ * dinger tokenId
*
* @return tokenId
*/
@@ -42,7 +42,7 @@
String decryptKey() default "";
/**
- * dingtalk secret
+ * dinger secret
*
* @return secret
*/
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerMarkdown.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerMarkdown.java
index 9323d73..1f0c942 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerMarkdown.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerMarkdown.java
@@ -35,7 +35,7 @@
*
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerScan.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerScan.java
index 153721c..8f32a07 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerScan.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerScan.java
@@ -24,7 +24,7 @@
* DingerScan
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerText.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerText.java
index a7dbce2..78f8de0 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerText.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerText.java
@@ -28,7 +28,7 @@
*
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerTokenId.java b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerTokenId.java
index fcbb6f2..74ef72c 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/DingerTokenId.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/DingerTokenId.java
@@ -21,7 +21,7 @@
* DingerTokenId
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
@@ -33,7 +33,7 @@
String value();
/**
- * @return dingtalk sign key
+ * @return dinger sign key
*/
String secret() default "";
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/Keyword.java b/src/main/java/com/github/jaemon/dinger/core/annatations/Keyword.java
index c83a9b1..7a4567c 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/Keyword.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/Keyword.java
@@ -21,11 +21,12 @@
* Keyword(quick locate to servive log)
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
+@Deprecated
public @interface Keyword {
boolean keyword() default true;
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/annatations/Parameter.java b/src/main/java/com/github/jaemon/dinger/core/annatations/Parameter.java
index d88b799..fac53a1 100644
--- a/src/main/java/com/github/jaemon/dinger/core/annatations/Parameter.java
+++ b/src/main/java/com/github/jaemon/dinger/core/annatations/Parameter.java
@@ -21,7 +21,7 @@
* Parameter
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/main/java/com/github/jaemon/dinger/entity/DingerCallback.java b/src/main/java/com/github/jaemon/dinger/core/entity/DingerCallback.java
similarity index 79%
rename from src/main/java/com/github/jaemon/dinger/entity/DingerCallback.java
rename to src/main/java/com/github/jaemon/dinger/core/entity/DingerCallback.java
index 8f70ac3..3a34952 100644
--- a/src/main/java/com/github/jaemon/dinger/entity/DingerCallback.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/DingerCallback.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger.entity;
+package com.github.jaemon.dinger.core.entity;
import com.github.jaemon.dinger.exception.DingerException;
@@ -29,10 +29,6 @@ public class DingerCallback {
* 处理唯一id
*/
private String dkid;
- /**
- * 检索关键字(方便日志查询)
- */
- private String keyword;
/**
* 通知信息
*/
@@ -45,9 +41,8 @@ public class DingerCallback {
public DingerCallback() {
}
- public DingerCallback(String dkid, String keyword, T message, DingerException ex) {
+ public DingerCallback(String dkid, T message, DingerException ex) {
this.dkid = dkid;
- this.keyword = keyword;
this.message = message;
this.ex = ex;
}
@@ -60,14 +55,6 @@ public void setDkid(String dkid) {
this.dkid = dkid;
}
- public String getKeyword() {
- return keyword;
- }
-
- public void setKeyword(String keyword) {
- this.keyword = keyword;
- }
-
public T getMessage() {
return message;
}
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/DingerProperties.java b/src/main/java/com/github/jaemon/dinger/core/entity/DingerProperties.java
index 94f3700..5e9e177 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/DingerProperties.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/DingerProperties.java
@@ -55,11 +55,6 @@ public class DingerProperties implements InitializingBean {
* */
private String projectId;
- /**
- * 可选, 应用程序状态监控
- */
- private MonitorStatus monitor = new MonitorStatus();
-
/**
* 使用dinger时, 对应的 xml配置路径.
*
@@ -97,14 +92,6 @@ public void setProjectId(String projectId) {
this.projectId = projectId;
}
- public MonitorStatus getMonitor() {
- return monitor;
- }
-
- public void setMonitor(MonitorStatus monitor) {
- this.monitor = monitor;
- }
-
public String getDingerLocations() {
return dingerLocations;
}
@@ -159,7 +146,7 @@ public static class Dinger {
*
* 解密密钥获取方式
*
- * - java -jar dingtalk-spring-boot-starter-[4.0.0].jar [tokenId]
+ * - java -jar dinger-spring-boot-starter-[1.0.0].jar [tokenId]
* - ConfigTools.encrypt(tokenId)
*
*/
@@ -219,53 +206,14 @@ public void setAsync(boolean async) {
}
}
- public static class MonitorStatus {
- /**
- * 应用启动成功是否通知
- */
- private boolean success = false;
- /**
- * 应用启动失败是否通知
- */
- private boolean falied = false;
- /**
- * 应用退出是否通知
- */
- private boolean exit = false;
-
- public boolean isSuccess() {
- return success;
- }
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-
- public boolean isFalied() {
- return falied;
- }
-
- public void setFalied(boolean falied) {
- this.falied = falied;
- }
-
- public boolean isExit() {
- return exit;
- }
-
- public void setExit(boolean exit) {
- this.exit = exit;
- }
- }
-
@Override
public void afterPropertiesSet() throws Exception {
for (Map.Entry entry : dingers.entrySet()) {
DingerType dingerType = entry.getKey();
if (!dingerType.isEnabled()) {
- log.warn("dinger={} is disabled.", dingerType);
- dingers.remove(dingerType);
- continue;
+ throw new InvalidPropertiesFormatException(
+ String.format("dinger=%s is disabled", dingerType)
+ );
}
Dinger dinger = entry.getValue();
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/DingerRequest.java b/src/main/java/com/github/jaemon/dinger/core/entity/DingerRequest.java
new file mode 100644
index 0000000..ab946eb
--- /dev/null
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/DingerRequest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright ©2015-2020 Jaemon. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.jaemon.dinger.core.entity;
+
+import java.util.List;
+
+/**
+ * Dinger请求体
+ *
+ * @author Jaemon
+ * @since 1.0
+ */
+public class DingerRequest {
+ /** 消息内容 */
+ private String content;
+ /** 标题(dingtalk-markdown) */
+ private String title;
+ /** 艾特成员信息 */
+ private List phones;
+ /** 艾特成员 */
+ private boolean atAll = false;
+
+ private DingerRequest(String content) {
+ this.content = content;
+ }
+
+ private DingerRequest(String content, String title) {
+ this(content);
+ this.title = title;
+ }
+
+ private DingerRequest(String content, List phones) {
+ this.content = content;
+ this.phones = phones;
+ }
+
+ private DingerRequest(String content, boolean atAll) {
+ this.content = content;
+ this.atAll = atAll;
+ }
+
+ private DingerRequest(String content, String title, List phones) {
+ this(content, title);
+ this.phones = phones;
+ }
+
+ private DingerRequest(String content, String title, boolean atAll) {
+ this(content, atAll);
+ this.title = title;
+ }
+
+
+ public static DingerRequest request(String content) {
+ return new DingerRequest(content);
+ }
+
+ public static DingerRequest request(String content, String title) {
+ return new DingerRequest(content, title);
+ }
+
+ public static DingerRequest request(String content, List phones) {
+ return new DingerRequest(content, phones);
+ }
+
+ public static DingerRequest request(String content, boolean atAll) {
+ return new DingerRequest(content, atAll);
+ }
+
+ public static DingerRequest request(String content, String title, List phones) {
+ return new DingerRequest(content, title, phones);
+ }
+
+ public static DingerRequest request(String content, String title, boolean atAll) {
+ return new DingerRequest(content, title, atAll);
+ }
+
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public List getPhones() {
+ return phones;
+ }
+
+ public void setPhones(List phones) {
+ this.phones = phones;
+ }
+
+ public boolean isAtAll() {
+ return atAll;
+ }
+
+ public void setAtAll(boolean atAll) {
+ this.atAll = atAll;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/entity/DingerResult.java b/src/main/java/com/github/jaemon/dinger/core/entity/DingerResponse.java
similarity index 67%
rename from src/main/java/com/github/jaemon/dinger/entity/DingerResult.java
rename to src/main/java/com/github/jaemon/dinger/core/entity/DingerResponse.java
index 176edb8..3a4e3f0 100644
--- a/src/main/java/com/github/jaemon/dinger/entity/DingerResult.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/DingerResponse.java
@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger.entity;
+package com.github.jaemon.dinger.core.entity;
-import com.github.jaemon.dinger.entity.enums.ResultCode;
+import com.github.jaemon.dinger.core.entity.enums.DingerResponseCodeEnum;
/**
- * DingTalk Result
+ * Dinger响应体
*
* @author Jaemon
* @since 1.0
*/
-public class DingerResult {
+public class DingerResponse {
/**
* 响应码
*/
@@ -41,33 +41,33 @@ public class DingerResult {
*/
private String data;
- private DingerResult(ResultCode resultCode, String logid) {
+ private DingerResponse(DingerResponseCodeEnum resultCode, String logid) {
this.code = resultCode.code();
this.message = resultCode.message();
this.logid = logid;
}
- private DingerResult(ResultCode resultCode, String logid, String data) {
+ private DingerResponse(DingerResponseCodeEnum resultCode, String logid, String data) {
this.code = resultCode.code();
this.message = resultCode.message();
this.logid = logid;
this.data = data;
}
- public static DingerResult success(String logId, String data) {
- return new DingerResult(ResultCode.SUCCESS, logId, data);
+ public static DingerResponse success(String logId, String data) {
+ return new DingerResponse(DingerResponseCodeEnum.SUCCESS, logId, data);
}
- public static DingerResult success(ResultCode resultCode, String logId, String data) {
- return new DingerResult(resultCode, logId, data);
+ public static DingerResponse success(DingerResponseCodeEnum resultCode, String logId, String data) {
+ return new DingerResponse(resultCode, logId, data);
}
- public static DingerResult failed(String logid) {
- return new DingerResult(ResultCode.FAILED, logid);
+ public static DingerResponse failed(String logid) {
+ return new DingerResponse(DingerResponseCodeEnum.FAILED, logid);
}
- public static DingerResult failed(ResultCode resultCode, String logid) {
- return new DingerResult(resultCode, logid);
+ public static DingerResponse failed(DingerResponseCodeEnum resultCode, String logid) {
+ return new DingerResponse(resultCode, logid);
}
public String getCode() {
diff --git a/src/main/java/com/github/jaemon/dinger/entity/enums/Pairs.java b/src/main/java/com/github/jaemon/dinger/core/entity/Pairs.java
similarity index 94%
rename from src/main/java/com/github/jaemon/dinger/entity/enums/Pairs.java
rename to src/main/java/com/github/jaemon/dinger/core/entity/Pairs.java
index 441f1ee..92b377e 100644
--- a/src/main/java/com/github/jaemon/dinger/entity/enums/Pairs.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/Pairs.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger.entity.enums;
+package com.github.jaemon.dinger.core.entity;
/**
* K-V对
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/AsyncExecuteType.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/AsyncExecuteType.java
index 90f04fd..43ff461 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/enums/AsyncExecuteType.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/AsyncExecuteType.java
@@ -19,7 +19,7 @@
* AsyncExecuteType
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public enum AsyncExecuteType {
TRUE(true),
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerDefinitionType.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerDefinitionType.java
index 9e28683..51c30d7 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerDefinitionType.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerDefinitionType.java
@@ -25,7 +25,7 @@
* Dinger消息体定义类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public enum DingerDefinitionType {
diff --git a/src/main/java/com/github/jaemon/dinger/entity/enums/ResultCode.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerResponseCodeEnum.java
similarity index 87%
rename from src/main/java/com/github/jaemon/dinger/entity/enums/ResultCode.java
rename to src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerResponseCodeEnum.java
index 954a28b..47a373e 100644
--- a/src/main/java/com/github/jaemon/dinger/entity/enums/ResultCode.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerResponseCodeEnum.java
@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.github.jaemon.dinger.entity.enums;
+package com.github.jaemon.dinger.core.entity.enums;
/**
- * Result Code
+ * Dinger响应码
*
* @author Jaemon
* @since 1.0
*/
-public enum ResultCode {
+public enum DingerResponseCodeEnum {
SUCCESS("D000", "success"),
DINGER_DISABLED("D101", "Dinger未启用"),
@@ -36,7 +36,7 @@ public enum ResultCode {
private String code;
private String message;
- ResultCode(String code, String message) {
+ DingerResponseCodeEnum(String code, String message) {
this.code = code;
this.message = message;
}
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerType.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerType.java
index 7168fe7..dd5bb0f 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerType.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/DingerType.java
@@ -23,7 +23,7 @@
* Dinger类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public enum DingerType {
DINGTALK("钉钉", "https://oapi.dingtalk.com/robot/send?access_token", true),
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/ExceptionEnum.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/ExceptionEnum.java
new file mode 100644
index 0000000..e9d69f5
--- /dev/null
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/ExceptionEnum.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright ©2015-2020 Jaemon. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.jaemon.dinger.core.entity.enums;
+
+import com.github.jaemon.dinger.core.entity.Pairs;
+
+/**
+ * 异常枚举
+ *
+ * @author Jaemon
+ * @since 1.0
+ */
+public enum ExceptionEnum implements Pairs {
+ /** 发送异常, 1XXX, {@link com.github.jaemon.dinger.exception.SendMsgException} */
+ SEND_MSG(1000, "发送消息异常"),
+
+
+
+
+
+ /** 消息类型异常, {@link com.github.jaemon.dinger.exception.MsgTypeException} */
+ MSG_TYPE_CHECK(2000, "消息类型异常"),
+
+
+
+
+
+ /** 异步调用相关异常, {@link com.github.jaemon.dinger.exception.AsyncCallException} */
+ ASYNC_CALL(3000, "异步调用异常"),
+
+
+
+
+
+ /**
+ * dingTalkManagerBuilder 配置异常
+ */
+ MULTI_DINGER_SCAN_ERROR(4000, "配置了多个DingerScan注解"),
+ /** {@link com.github.jaemon.dinger.exception.ConfigurationException} */
+ CONFIG_ERROR(4001, "配置异常"),
+
+
+
+
+
+ /** 配置文件相关异常, 5XXX, {@link com.github.jaemon.dinger.exception.InvalidPropertiesFormatException} */
+ PROPERTIES_ERROR(5000, "配置文件异常"),
+
+
+
+
+
+ /** Dinger解析XML相关异常, 60XX */
+ DINER_XML_NAMESPACE_INVALID(6000, "xml文件namespace=%s无效"),
+ DINER_XML_MSGTYPE_INVALID(6001, "xml文件message type=%s无效"),
+
+ // TODO
+ DINGERDEFINITION_ERROR(6004, "dingerDefinition异常"),
+ DINGERDEFINITIONTYPE_ERROR(6005, "DingerDefinitionType异常"),
+
+
+ /** Dinger解析注解相关异常, 63XX */
+
+
+ /** Dinger解析公共相关异常, 65XX */
+ /** 注定DingerText和Dinger xml重复配置也会抛出该异常 */
+ DINGER_REPEATED_EXCEPTION(6500, "重复的DingerId=%s对象"),
+ DINGERDEFINITIONTYPE_UNDEFINED_KEY(6501, "当前key=%s在DingerDefinitionType中没定义"),
+
+
+
+
+
+ /** Multi Dinger解析相关异常, 70XX */
+ DINGER_CONFIG_HANDLER_EXCEPTION(7000, "DingerConfigHandler=%s中指定的dingerconfigs[%d]数据异常"),
+ MULTIDINGER_ALGORITHM_EXCEPTION(7001, "DingerConfigHandler=%s中算法为空"),
+
+ /** Multi Dinger属性注入相关异常, 75XX */
+ ALGORITHM_FIELD_INSTANCE_NOT_EXISTS(7500, "算法[%s]中属性字段[%s]实例不存在"),
+ ALGORITHM_FIELD_INSTANCE_NOT_MATCH(7501, "算法[%s]中属性字段[%s]实例不匹配"),
+ ALGORITHM_FIELD_INJECT_FAILED(7502, "算法[%s]中属性字段[%s]注入失败"),
+
+
+ /** 未知异常 */
+ UNKNOWN(9999, "未知异常")
+ ;
+
+
+ private int code;
+ private String message;
+
+ ExceptionEnum(int code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer code() {
+ return code;
+ }
+
+ @Override
+ public String desc() {
+ return message;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageMainType.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageMainType.java
index b853458..6876f1f 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageMainType.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageMainType.java
@@ -19,7 +19,7 @@
* 消息体定义主类型(消息体xml定义和注解定义)
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public enum MessageMainType {
/** xml dinger msg */
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageSubType.java b/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageSubType.java
index efc7259..dcb72e0 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageSubType.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/enums/MessageSubType.java
@@ -32,7 +32,7 @@
* 消息体定义子类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public enum MessageSubType {
TEXT {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/BeanTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/BeanTag.java
index fc6738e..802c883 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/BeanTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/BeanTag.java
@@ -25,7 +25,7 @@
* BeanTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name="dinger")
public class BeanTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/BodyTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/BodyTag.java
index dd0ccdb..d59ff0a 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/BodyTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/BodyTag.java
@@ -25,7 +25,7 @@
* BodyTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name="body")
public class BodyTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/ConfigurationTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/ConfigurationTag.java
index ef0c101..a0e59e8 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/ConfigurationTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/ConfigurationTag.java
@@ -25,7 +25,7 @@
* ConfigurationTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name = "configuration")
public class ConfigurationTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/MessageTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/MessageTag.java
index 6232960..3f681b2 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/MessageTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/MessageTag.java
@@ -24,7 +24,7 @@
* MessageTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name = "message")
public class MessageTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhoneTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhoneTag.java
index 08bed92..4c087c2 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhoneTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhoneTag.java
@@ -22,7 +22,7 @@
* PhoneTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name = "phone")
public class PhoneTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhonesTag.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhonesTag.java
index dc0d1f9..b1e244e 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhonesTag.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/PhonesTag.java
@@ -25,7 +25,7 @@
* PhonesTag
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name = "phones")
public class PhonesTag {
diff --git a/src/main/java/com/github/jaemon/dinger/core/entity/xml/TokenId.java b/src/main/java/com/github/jaemon/dinger/core/entity/xml/TokenId.java
index 3aaf248..4c37b9c 100644
--- a/src/main/java/com/github/jaemon/dinger/core/entity/xml/TokenId.java
+++ b/src/main/java/com/github/jaemon/dinger/core/entity/xml/TokenId.java
@@ -25,7 +25,7 @@
* TokenId
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
@XmlRootElement(name = "token-id")
public class TokenId {
diff --git a/src/main/java/com/github/jaemon/dinger/core/package-info.java b/src/main/java/com/github/jaemon/dinger/core/package-info.java
index d6db2c6..7471422 100644
--- a/src/main/java/com/github/jaemon/dinger/core/package-info.java
+++ b/src/main/java/com/github/jaemon/dinger/core/package-info.java
@@ -18,6 +18,6 @@
* Dinger框架核心包
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
package com.github.jaemon.dinger.core;
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/core/spring/DingerFactoryBean.java b/src/main/java/com/github/jaemon/dinger/core/spring/DingerFactoryBean.java
index ccb7754..2fd263d 100644
--- a/src/main/java/com/github/jaemon/dinger/core/spring/DingerFactoryBean.java
+++ b/src/main/java/com/github/jaemon/dinger/core/spring/DingerFactoryBean.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.core.spring;
-import com.github.jaemon.dinger.DingerSender;
+import com.github.jaemon.dinger.core.DingerRobot;
import com.github.jaemon.dinger.core.DingerSession;
import com.github.jaemon.dinger.core.entity.DingerProperties;
import org.springframework.beans.factory.FactoryBean;
@@ -25,13 +25,13 @@
* DingerFactoryBean
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerFactoryBean implements FactoryBean {
private Class dingerInterface;
@Autowired
- private DingerSender dingerSender;
+ private DingerRobot dingerRobot;
@Autowired
private DingerProperties dingerProperties;
@@ -41,7 +41,7 @@ public DingerFactoryBean(Class dingerInterface) {
@Override
public T getObject() throws Exception {
- return new DingerSession(dingerSender, dingerProperties).getDinger(this.dingerInterface);
+ return new DingerSession(dingerRobot, dingerProperties).getDinger(this.dingerInterface);
}
@Override
diff --git a/src/main/java/com/github/jaemon/dinger/core/spring/DingerScannerRegistrar.java b/src/main/java/com/github/jaemon/dinger/core/spring/DingerScannerRegistrar.java
index f1c4e07..864dee7 100644
--- a/src/main/java/com/github/jaemon/dinger/core/spring/DingerScannerRegistrar.java
+++ b/src/main/java/com/github/jaemon/dinger/core/spring/DingerScannerRegistrar.java
@@ -16,9 +16,8 @@
package com.github.jaemon.dinger.core.spring;
import com.github.jaemon.dinger.core.annatations.DingerScan;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
import com.github.jaemon.dinger.exception.DingerException;
-import com.github.jaemon.dinger.listeners.ApplicationEventTimeTable;
import com.github.jaemon.dinger.listeners.DingerListenersProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +38,7 @@
* DingerScannerRegistrar
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerScannerRegistrar
extends DingerListenersProperty
@@ -53,7 +52,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
boolean isDebugEnabled = log.isDebugEnabled();
log.info("ready to execute dingerScanner...");
try {
- List> dingerClasses = ApplicationEventTimeTable.dingerClasses();
+ List> dingerClasses = DingerListenersProperty.dingerClasses();
if (!dingerClasses.isEmpty()) {
registerBeanDefinition(registry, dingerClasses);
diff --git a/src/main/java/com/github/jaemon/dinger/dingtalk/DingTalkDefinitionGenerator.java b/src/main/java/com/github/jaemon/dinger/dingtalk/DingTalkDefinitionGenerator.java
index cca3c55..1f64bd8 100644
--- a/src/main/java/com/github/jaemon/dinger/dingtalk/DingTalkDefinitionGenerator.java
+++ b/src/main/java/com/github/jaemon/dinger/dingtalk/DingTalkDefinitionGenerator.java
@@ -31,7 +31,7 @@
* 钉钉消息体定义生成类
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingTalkDefinitionGenerator extends DingerDefinitionHandler {
private static final Logger log = LoggerFactory.getLogger(DingerDefinitionGenerator.class);
diff --git a/src/main/java/com/github/jaemon/dinger/dingtalk/entity/DingTalkMessage.java b/src/main/java/com/github/jaemon/dinger/dingtalk/entity/DingTalkMessage.java
index 457d9e4..332b0dc 100644
--- a/src/main/java/com/github/jaemon/dinger/dingtalk/entity/DingTalkMessage.java
+++ b/src/main/java/com/github/jaemon/dinger/dingtalk/entity/DingTalkMessage.java
@@ -22,7 +22,7 @@
* DingTalk请求体
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingTalkMessage extends MsgType {
public DingTalkMessage() {
diff --git a/src/main/java/com/github/jaemon/dinger/dingtalk/entity/enums/DingTalkMsgType.java b/src/main/java/com/github/jaemon/dinger/dingtalk/entity/enums/DingTalkMsgType.java
index aa69606..4decf4d 100644
--- a/src/main/java/com/github/jaemon/dinger/dingtalk/entity/enums/DingTalkMsgType.java
+++ b/src/main/java/com/github/jaemon/dinger/dingtalk/entity/enums/DingTalkMsgType.java
@@ -19,7 +19,7 @@
* DingTalk支持的消息类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public enum DingTalkMsgType {
/**
diff --git a/src/main/java/com/github/jaemon/dinger/dingtalk/package-info.java b/src/main/java/com/github/jaemon/dinger/dingtalk/package-info.java
index 53f13bd..f3c2d63 100644
--- a/src/main/java/com/github/jaemon/dinger/dingtalk/package-info.java
+++ b/src/main/java/com/github/jaemon/dinger/dingtalk/package-info.java
@@ -15,9 +15,9 @@
*/
/**
- * DingTalk适配包
+ * 支持DingTalk包
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
package com.github.jaemon.dinger.dingtalk;
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/entity/enums/ExceptionEnum.java b/src/main/java/com/github/jaemon/dinger/entity/enums/ExceptionEnum.java
deleted file mode 100644
index d2ce35c..0000000
--- a/src/main/java/com/github/jaemon/dinger/entity/enums/ExceptionEnum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright ©2015-2020 Jaemon. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.github.jaemon.dinger.entity.enums;
-
-/**
- * 异常枚举
- *
- * @author Jaemon
- * @since 1.0
- */
-public enum ExceptionEnum implements Pairs {
- SEND_MSG(1000, "发送消息异常"),
- MSG_TYPE_CHECK(2000, "消息类型异常"),
- ASYNC_CALL(3000, "异步调用异常"),
- /**
- * dingTalkManagerBuilder 配置异常
- */
- CONFIG_ERROR(4000, "配置异常"),
- /**
- *
- */
- PROPERTIES_ERROR(5000, "配置文件异常"),
-
- DINER_XML_ANALYSIS_EXCEPTION(6000, "Dinger xml解析异常"),
- DINGERSCAN_REPEATED_EXCEPTION(6001, "DingerScan注解重复配置"),
- /** 注定DingerText和Dinger xml重复配置也会抛出该异常 */
- DINGER_CONFIG_REPEATED_EXCEPTION(6002, "重复的DingerId对象"),
- GLOBAL_MULTIDINGER_CONFIG_EXCEPTION(6003, "全局多Dinger配置错误"),
- MULTIDINGER_ALGORITHM_EXCEPTION(6004, "多Dinger配置处理器算法不可为空"),
- MULTI_DINGERCONFIGS_EXCEPTION(6005, "多Dinger配置DingerConfig异常"),
-
- REGISTER_DINGERDEFINITION_ERROR(6006, "注册dingerDefinition异常"),
- DINGERDEFINITION_ERROR(6007, "dingerDefinition异常"),
- DINGERDEFINITIONTYPE_ERROR(6008, "DingerDefinitionType异常"),
-
- UNKNOWN(9999, "未知异常")
- ;
-
-
- private int code;
- private String message;
-
- ExceptionEnum(int code, String message) {
- this.code = code;
- this.message = message;
- }
-
- @Override
- public Integer code() {
- return code;
- }
-
- @Override
- public String desc() {
- return message;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/exception/AsyncCallException.java b/src/main/java/com/github/jaemon/dinger/exception/AsyncCallException.java
index b5b2876..6fcb741 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/AsyncCallException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/AsyncCallException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
/**
* 异步调用异常
diff --git a/src/main/java/com/github/jaemon/dinger/exception/ConfigurationException.java b/src/main/java/com/github/jaemon/dinger/exception/ConfigurationException.java
index 74d0a39..edff41c 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/ConfigurationException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/ConfigurationException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
/**
* 配置异常
diff --git a/src/main/java/com/github/jaemon/dinger/exception/DingerXmlAnalysisException.java b/src/main/java/com/github/jaemon/dinger/exception/DingerAnalysisException.java
similarity index 64%
rename from src/main/java/com/github/jaemon/dinger/exception/DingerXmlAnalysisException.java
rename to src/main/java/com/github/jaemon/dinger/exception/DingerAnalysisException.java
index 48b3fa1..67188fc 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/DingerXmlAnalysisException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/DingerAnalysisException.java
@@ -15,20 +15,20 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.Pairs;
/**
- * DingerXmlAnalysisException
+ * Dinger解析异常
*
* @author Jaemon
* @since 1.0
*/
-public class DingerXmlAnalysisException extends DingerException {
- public DingerXmlAnalysisException(String msg) {
- super(msg, ExceptionEnum.DINER_XML_ANALYSIS_EXCEPTION);
+public class DingerAnalysisException extends DingerException {
+ public DingerAnalysisException(Pairs pairs) {
+ super(pairs);
}
- public DingerXmlAnalysisException(Throwable cause) {
- super(cause, ExceptionEnum.DINER_XML_ANALYSIS_EXCEPTION);
+ public DingerAnalysisException(Pairs pairs, String message) {
+ super(message, pairs);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/exception/DingerException.java b/src/main/java/com/github/jaemon/dinger/exception/DingerException.java
index 61eb180..d65d11e 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/DingerException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/DingerException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.Pairs;
+import com.github.jaemon.dinger.core.entity.Pairs;
/**
* 异常类
@@ -26,17 +26,22 @@
public class DingerException extends RuntimeException {
private Pairs pairs;
- public DingerException(Pairs pairs) {
- super(pairs.desc().toString());
+ public DingerException(Pairs pairs) {
+ super(pairs.desc());
this.pairs = pairs;
}
- public DingerException(String msg, Pairs pairs) {
+ public DingerException(String msg, Pairs pairs) {
super(msg);
this.pairs = pairs;
}
- public DingerException(Throwable cause, Pairs pairs) {
+ public DingerException(Pairs pairs, Object... msgArgs) {
+ super(String.format(pairs.desc(), msgArgs));
+ this.pairs = pairs;
+ }
+
+ public DingerException(Throwable cause, Pairs pairs) {
super(cause);
this.pairs = pairs;
}
diff --git a/src/main/java/com/github/jaemon/dinger/exception/InvalidPropertiesFormatException.java b/src/main/java/com/github/jaemon/dinger/exception/InvalidPropertiesFormatException.java
index 1da4681..9159abb 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/InvalidPropertiesFormatException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/InvalidPropertiesFormatException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
/**
* Invalid Properties Format Exception
diff --git a/src/main/java/com/github/jaemon/dinger/exception/MsgTypeException.java b/src/main/java/com/github/jaemon/dinger/exception/MsgTypeException.java
index f75021c..407d14d 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/MsgTypeException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/MsgTypeException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
/**
* 类型异常
diff --git a/src/main/java/com/github/jaemon/dinger/exception/DingerScanRepeatedException.java b/src/main/java/com/github/jaemon/dinger/exception/MultiDingerRegisterException.java
similarity index 58%
rename from src/main/java/com/github/jaemon/dinger/exception/DingerScanRepeatedException.java
rename to src/main/java/com/github/jaemon/dinger/exception/MultiDingerRegisterException.java
index 7a79ad2..aeeb5bb 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/DingerScanRepeatedException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/MultiDingerRegisterException.java
@@ -15,24 +15,21 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.Pairs;
/**
- * DingerScanRepeatedException
+ * 多Dinger配置注册异常
*
* @author Jaemon
* @since 1.0
*/
-public class DingerScanRepeatedException extends DingerException {
- public DingerScanRepeatedException() {
- super(ExceptionEnum.DINGERSCAN_REPEATED_EXCEPTION);
+public class MultiDingerRegisterException extends DingerException {
+ public MultiDingerRegisterException(Pairs pairs) {
+ super(pairs);
}
- public DingerScanRepeatedException(String msg) {
- super(msg, ExceptionEnum.DINGERSCAN_REPEATED_EXCEPTION);
+ public MultiDingerRegisterException(Pairs pairs, String message) {
+ super(message, pairs);
}
- public DingerScanRepeatedException(Throwable cause) {
- super(cause, ExceptionEnum.DINGERSCAN_REPEATED_EXCEPTION);
- }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/exception/SendMsgException.java b/src/main/java/com/github/jaemon/dinger/exception/SendMsgException.java
index afe1eeb..6ab4421 100644
--- a/src/main/java/com/github/jaemon/dinger/exception/SendMsgException.java
+++ b/src/main/java/com/github/jaemon/dinger/exception/SendMsgException.java
@@ -15,7 +15,7 @@
*/
package com.github.jaemon.dinger.exception;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
/**
* 发送消息异常
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/ApplicationEventTimeTable.java b/src/main/java/com/github/jaemon/dinger/listeners/ApplicationEventTimeTable.java
deleted file mode 100644
index 96b6716..0000000
--- a/src/main/java/com/github/jaemon/dinger/listeners/ApplicationEventTimeTable.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright ©2015-2020 Jaemon. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.github.jaemon.dinger.listeners;
-
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-/**
- * ApplicationEventTimeTable
- *
- * @author Jaemon
- * @since 1.0
- */
-public final class ApplicationEventTimeTable extends DingerListenersProperty {
- /**
- * 禁用dinger监控功能
- *
- * -Ddinger.monitor.disabled=true
- * */
- static final String DISABLED_DINTALK_MONITOR = "dinger.monitor.disabled";
- /**
- * startTime
- */
- static long startTime = 0;
- /**
- * successTime
- */
- static long successTime = 0;
- /**
- * failedTime
- */
- static long failedTime = 0;
- /**
- * exitTime
- */
- static long exitTime = 0;
-
- private ApplicationEventTimeTable() {
- }
-
- public static long startTime() {
- return startTime;
- }
-
- public static long successTime() {
- return successTime;
- }
-
- public static long failedTime() {
- return failedTime;
- }
-
- public static long exitTime() {
- return exitTime;
- }
-
-
- protected static void clear() {
- ApplicationEventTimeTable.startTime = 0;
- ApplicationEventTimeTable.successTime = 0;
- ApplicationEventTimeTable.failedTime = 0;
- ApplicationEventTimeTable.exitTime = 0;
- primarySources = new HashSet<>();
- dingerClasses = new ArrayList<>();
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/DingerListenersProperty.java b/src/main/java/com/github/jaemon/dinger/listeners/DingerListenersProperty.java
index 5a92ef3..a454b09 100644
--- a/src/main/java/com/github/jaemon/dinger/listeners/DingerListenersProperty.java
+++ b/src/main/java/com/github/jaemon/dinger/listeners/DingerListenersProperty.java
@@ -24,7 +24,7 @@
* ApplicationEventTimeTable
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class DingerListenersProperty {
/**
@@ -55,4 +55,9 @@ protected static void emptyDingerClasses() {
enabledDingerTypes = Arrays.stream(DingerType.values()).filter(e -> e.isEnabled()).collect(Collectors.toList());
}
+ protected static void clear() {
+ DingerListenersProperty.primarySources().clear();
+ DingerListenersProperty.dingerClasses().clear();
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/DingerXmlPreparedEvent.java b/src/main/java/com/github/jaemon/dinger/listeners/DingerXmlPreparedEvent.java
index b0ef336..e54602e 100644
--- a/src/main/java/com/github/jaemon/dinger/listeners/DingerXmlPreparedEvent.java
+++ b/src/main/java/com/github/jaemon/dinger/listeners/DingerXmlPreparedEvent.java
@@ -17,7 +17,8 @@
import com.github.jaemon.dinger.core.DingerDefinitionResolver;
import com.github.jaemon.dinger.core.entity.enums.DingerType;
-import com.github.jaemon.dinger.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.core.entity.enums.ExceptionEnum;
+import com.github.jaemon.dinger.exception.DingerAnalysisException;
import com.github.jaemon.dinger.exception.DingerException;
import com.github.jaemon.dinger.utils.DingerUtils;
import com.github.jaemon.dinger.core.DingerConfig;
@@ -33,7 +34,7 @@
* DingerXmlPreparedEvent
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class DingerXmlPreparedEvent
extends DingerDefinitionResolver
@@ -47,7 +48,9 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
registerDefaultDingerConfig(event.getEnvironment());
try {
- ApplicationEventTimeTable.dingerClasses = doAnalysis(event);
+ DingerListenersProperty.dingerClasses = doAnalysis(event);
+ } catch (DingerException ex) {
+ throw new DingerAnalysisException(ex.getPairs(), ex.getMessage());
} catch (Exception ex) {
throw new DingerException(ex, ExceptionEnum.UNKNOWN);
}
@@ -78,7 +81,7 @@ private void registerDefaultDingerConfig(Environment environment) {
String secret = environment.getProperty(secretProp);
boolean decrypt = getProperty(environment, decryptProp);
boolean async = getProperty(environment, asyncExecuteProp);
- DingerConfig defaultDingerConfig = new DingerConfig(tokenId);
+ DingerConfig defaultDingerConfig = DingerConfig.instance(tokenId);
defaultDingerConfig.setDingerType(dingerType);
defaultDingerConfig.setSecret(secret);
if (decrypt) {
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/ExitEventListener.java b/src/main/java/com/github/jaemon/dinger/listeners/ExitEventListener.java
index bac34e2..f777cf8 100644
--- a/src/main/java/com/github/jaemon/dinger/listeners/ExitEventListener.java
+++ b/src/main/java/com/github/jaemon/dinger/listeners/ExitEventListener.java
@@ -16,22 +16,11 @@
package com.github.jaemon.dinger.listeners;
import com.github.jaemon.dinger.multi.MultiDingerRefresh;
-import com.github.jaemon.dinger.DingerSender;
-import com.github.jaemon.dinger.core.entity.DingerProperties;
-import com.github.jaemon.dinger.entity.DingerResult;
-import com.github.jaemon.dinger.core.entity.MsgType;
-import com.github.jaemon.dinger.support.MonitorEventNotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
-import static com.github.jaemon.dinger.constant.DingerConstant.DINGER_PREFIX;
-import static com.github.jaemon.dinger.constant.DingerConstant.EXIT_KEYWORD;
-import static com.github.jaemon.dinger.listeners.ApplicationEventTimeTable.DISABLED_DINTALK_MONITOR;
-
/**
* Exit Listener
*
@@ -45,50 +34,12 @@ public class ExitEventListener
@Override
public void onApplicationEvent(ContextClosedEvent event) {
- boolean debugEnabled = log.isDebugEnabled();
-
- try {
- String monitor = System.getProperty(DISABLED_DINTALK_MONITOR);
- if (monitor != null && "true".equals(monitor.trim())) {
- return;
- }
-
- ApplicationContext applicationContext = event.getApplicationContext();
-
- if (AnnotationConfigServletWebServerApplicationContext.class.isInstance(applicationContext)
- && ApplicationEventTimeTable.exitTime == 0) {
- if (debugEnabled) {
- log.debug("ready to execute ContextClosedEvent.");
- }
- ApplicationEventTimeTable.exitTime = event.getTimestamp();
- DingerProperties properties = applicationContext.getBean(DingerProperties.class);
-
- if (properties.isEnabled()
- && properties.getMonitor().isExit()
- // exclude start-up failed
- && ApplicationEventTimeTable.successTime() > 0) {
- DingerSender dingTalkRobot = applicationContext.getBean(DingerSender.class);
- MonitorEventNotification monitorEventNotification = applicationContext.getBean(MonitorEventNotification.class);
- String projectId = properties.getProjectId();
- projectId = projectId == null ? DINGER_PREFIX : projectId;
-
- MsgType message = monitorEventNotification.exit(event, projectId);
- String keyword = projectId + EXIT_KEYWORD;
- DingerResult result = dingTalkRobot.send(keyword, message);
- if (debugEnabled) {
- log.debug("keyword={}, result={}.", keyword, result.toString());
- }
- }
- }
- } finally {
- // support devtools
- refresh();
- }
-
+ // support devtools
+ refresh();
}
private void refresh() {
multiDingerRefresh();
- ApplicationEventTimeTable.clear();
+ DingerListenersProperty.clear();
}
}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/FailedEventListener.java b/src/main/java/com/github/jaemon/dinger/listeners/FailedEventListener.java
deleted file mode 100644
index a8c8fd3..0000000
--- a/src/main/java/com/github/jaemon/dinger/listeners/FailedEventListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright ©2015-2020 Jaemon. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.github.jaemon.dinger.listeners;
-
-import com.github.jaemon.dinger.DingerSender;
-import com.github.jaemon.dinger.constant.DingerConstant;
-import com.github.jaemon.dinger.core.entity.DingerProperties;
-import com.github.jaemon.dinger.core.entity.MsgType;
-import com.github.jaemon.dinger.entity.DingerResult;
-import com.github.jaemon.dinger.support.MonitorEventNotification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.context.event.ApplicationFailedEvent;
-import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationListener;
-
-/**
- * Failed Listener
- *
- * @author Jaemon
- * @since 1.0
- */
-public class FailedEventListener implements ApplicationListener {
- private static final Logger log = LoggerFactory.getLogger(FailedEventListener.class);
-
- @Override
- public void onApplicationEvent(ApplicationFailedEvent event) {
- boolean debugEnabled = log.isDebugEnabled();
-
- String monitor = System.getProperty(ApplicationEventTimeTable.DISABLED_DINTALK_MONITOR);
- if (monitor != null && "true".equals(monitor.trim())) {
- return;
- }
-
- ApplicationContext applicationContext = event.getApplicationContext();
- if (applicationContext == null) {
- return;
- }
-
- if (AnnotationConfigServletWebServerApplicationContext.class.isInstance(applicationContext)
- && ApplicationEventTimeTable.failedTime == 0) {
- if (debugEnabled) {
- log.debug("ready to execute ApplicationFailedEvent.");
- }
- ApplicationEventTimeTable.failedTime = event.getTimestamp();
- DingerProperties properties = applicationContext.getBean(DingerProperties.class);
-
- if (properties.isEnabled()
- && properties.getMonitor().isFalied()) {
- DingerSender dingTalkRobot = applicationContext.getBean(DingerSender.class);
- MonitorEventNotification monitorEventNotification = applicationContext.getBean(MonitorEventNotification.class);
- String projectId = properties.getProjectId();
- projectId = projectId == null ? DingerConstant.DINGER_PREFIX : projectId;
-
- MsgType message = monitorEventNotification.failed(event, projectId);
- String keyword = projectId + DingerConstant.FAILED_KEYWORD;
- DingerResult result = dingTalkRobot.send(keyword, message);
- if (debugEnabled) {
- log.debug("keyword={}, result={}.", keyword, result.toString());
- }
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/github/jaemon/dinger/listeners/StartEventListener.java b/src/main/java/com/github/jaemon/dinger/listeners/StartEventListener.java
index 6a04795..926fc74 100644
--- a/src/main/java/com/github/jaemon/dinger/listeners/StartEventListener.java
+++ b/src/main/java/com/github/jaemon/dinger/listeners/StartEventListener.java
@@ -35,15 +35,6 @@ public class StartEventListener implements ApplicationListener 0) {
- log.info("dingtalk has already been initialized.");
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("ready to execute ApplicationStartingEvent.");
- }
- ApplicationEventTimeTable.startTime = event.getTimestamp();
-
Set
*
- * @since 2.0
+ * @since 1.0
* @version $Id: JVMRandom.java 471626 2006-11-06 04:02:09Z bayard $
*/
public final class JVMRandom extends Random {
diff --git a/src/main/java/com/github/jaemon/dinger/utils/PackageUtils.java b/src/main/java/com/github/jaemon/dinger/utils/PackageUtils.java
index 763e82f..a719fbb 100644
--- a/src/main/java/com/github/jaemon/dinger/utils/PackageUtils.java
+++ b/src/main/java/com/github/jaemon/dinger/utils/PackageUtils.java
@@ -37,7 +37,7 @@
* PackageUtils
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class PackageUtils {
private static final Logger log = LoggerFactory.getLogger(PackageUtils.class);
diff --git a/src/main/java/com/github/jaemon/dinger/utils/RandomUtils.java b/src/main/java/com/github/jaemon/dinger/utils/RandomUtils.java
index 627e96d..2a82eb2 100644
--- a/src/main/java/com/github/jaemon/dinger/utils/RandomUtils.java
+++ b/src/main/java/com/github/jaemon/dinger/utils/RandomUtils.java
@@ -23,7 +23,7 @@
* method and its system-wide Random
object.
*
* @author Gary D. Gregory
- * @since 2.0
+ * @since 1.0
* @version $Id: RandomUtils.java 471626 2006-11-06 04:02:09Z bayard $
*/
public class RandomUtils {
diff --git a/src/main/java/com/github/jaemon/dinger/utils/XmlUtils.java b/src/main/java/com/github/jaemon/dinger/utils/XmlUtils.java
index 1c9f8d0..1483705 100644
--- a/src/main/java/com/github/jaemon/dinger/utils/XmlUtils.java
+++ b/src/main/java/com/github/jaemon/dinger/utils/XmlUtils.java
@@ -27,7 +27,7 @@
* XML字符串JavaBean对象互转工具类
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
public class XmlUtils {
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/WeTalkDefinitionGenerator.java b/src/main/java/com/github/jaemon/dinger/wetalk/WeTalkDefinitionGenerator.java
index f4622c8..ae82051 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/WeTalkDefinitionGenerator.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/WeTalkDefinitionGenerator.java
@@ -29,7 +29,7 @@
* 企业微信消息体定义生成类
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeTalkDefinitionGenerator extends DingerDefinitionHandler {
/**
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeImage.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeImage.java
index cde45a5..8ad13b4 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeImage.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeImage.java
@@ -23,7 +23,7 @@
* 企业微信-消息类型-图片类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeImage extends WeTalkMessage {
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeMarkdown.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeMarkdown.java
index 1a973e8..bdc760c 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeMarkdown.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeMarkdown.java
@@ -24,7 +24,7 @@
* 企业微信-消息类型-markdown类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeMarkdown extends WeTalkMessage {
private Markdown markdown;
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeNews.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeNews.java
index 5eeda6e..97da27f 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeNews.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeNews.java
@@ -24,7 +24,7 @@
* 企业微信-消息类型-图文类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeNews extends WeTalkMessage {
/** 图文类型 */
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeTalkMessage.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeTalkMessage.java
index af3dfee..041f131 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeTalkMessage.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeTalkMessage.java
@@ -22,7 +22,7 @@
* WeTalk请求体
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeTalkMessage extends MsgType {
public WeTalkMessage() {
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeText.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeText.java
index 612adad..400772d 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeText.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/WeText.java
@@ -25,7 +25,7 @@
* 企业微信-消息类型-文本类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class WeText extends WeTalkMessage {
private Text text;
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/entity/enums/WeTalkMsgType.java b/src/main/java/com/github/jaemon/dinger/wetalk/entity/enums/WeTalkMsgType.java
index a0cce50..f08388c 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/entity/enums/WeTalkMsgType.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/entity/enums/WeTalkMsgType.java
@@ -19,7 +19,7 @@
* WeTalk支持的消息类型
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public enum WeTalkMsgType {
/**
diff --git a/src/main/java/com/github/jaemon/dinger/wetalk/package-info.java b/src/main/java/com/github/jaemon/dinger/wetalk/package-info.java
index 214e7fd..e6571c9 100644
--- a/src/main/java/com/github/jaemon/dinger/wetalk/package-info.java
+++ b/src/main/java/com/github/jaemon/dinger/wetalk/package-info.java
@@ -15,9 +15,9 @@
*/
/**
- * WeTalk适配包
+ * 支持WeTalk包
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
package com.github.jaemon.dinger.wetalk;
\ No newline at end of file
diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories
index 6cc3128..30d5c78 100644
--- a/src/main/resources/META-INF/spring.factories
+++ b/src/main/resources/META-INF/spring.factories
@@ -8,7 +8,5 @@ com.github.jaemon.dinger.config.DingerThreadPoolConfig
# Application Listeners
org.springframework.context.ApplicationListener=\
com.github.jaemon.dinger.listeners.StartEventListener,\
-com.github.jaemon.dinger.listeners.SuccessEventListener,\
-com.github.jaemon.dinger.listeners.FailedEventListener,\
com.github.jaemon.dinger.listeners.ExitEventListener,\
com.github.jaemon.dinger.listeners.DingerXmlPreparedEvent
\ No newline at end of file
diff --git a/src/test/java/com/github/jaemon/dinger/core/OrderDinger.java b/src/test/java/com/github/jaemon/dinger/core/OrderDinger.java
index e5f673d..9f789f3 100644
--- a/src/test/java/com/github/jaemon/dinger/core/OrderDinger.java
+++ b/src/test/java/com/github/jaemon/dinger/core/OrderDinger.java
@@ -17,7 +17,7 @@
import com.dingerframework.core.annatations.*;
import com.github.jaemon.dinger.core.annatations.*;
-import com.github.jaemon.dinger.entity.DingerResult;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
import java.math.BigDecimal;
@@ -25,14 +25,14 @@
* OrderDinger template
*
* @author Jaemon
- * @since 2.0
+ * @since 1.0
*/
//@Dinger
//@@DingerClose
public interface OrderDinger {
@DingerText(value = "订单号${orderNum}下单成功啦, 下单金额${amt}", phones = {"13520200906"})
- DingerResult orderSuccess(
+ DingerResponse orderSuccess(
@Keyword String keyword,
@Parameter("orderNum") String orderNo,
@Parameter("amt") BigDecimal amt);
@@ -47,7 +47,7 @@ DingerResult orderSuccess(
value = "87dbeb7bc28894c3bdcc3d12457228ad590164327b5f427cd85f9025ebb350cf",
secret = "SAQ23a9039bb01f2dcd017b90ab8e9dda1355f97c9016f37ff371ec8124327c7f09")
)
- DingerResult orderFailed(
+ DingerResponse orderFailed(
String orderNo,
int num,
boolean flag);
diff --git a/src/test/java/com/github/jaemon/dinger/core/UserDinger.java b/src/test/java/com/github/jaemon/dinger/core/UserDinger.java
index 56197ab..6fa4008 100644
--- a/src/test/java/com/github/jaemon/dinger/core/UserDinger.java
+++ b/src/test/java/com/github/jaemon/dinger/core/UserDinger.java
@@ -19,14 +19,14 @@
import com.github.jaemon.dinger.multi.annotations.MultiHandler;
import com.github.jaemon.dinger.core.annatations.DingerMarkdown;
import com.github.jaemon.dinger.core.annatations.DingerText;
-import com.github.jaemon.dinger.entity.DingerResult;
+import com.github.jaemon.dinger.core.entity.DingerResponse;
import com.github.jaemon.dinger.multi.handler.UserDingerConfigHandler;
/**
* UserDinger
*
* @author Jaemon
- * @since 3.0
+ * @since 1.0
*/
// 标识对应的处理器
@MultiHandler(UserDingerConfigHandler.class)
@@ -40,7 +40,7 @@ public interface UserDinger {
* result
*/
@DingerText(value = "恭喜用户${userName}注册成功!", phones = {"13520200906"})
- DingerResult userRegister(String userName);
+ DingerResponse userRegister(String userName);
/**
* 用户注销通知
@@ -57,5 +57,5 @@ public interface UserDinger {
title = "用户注销反馈",
phones = {"13520200906"}
)
- DingerResult userLogout(@Parameter("userId") Long id, String userName);
+ DingerResponse userLogout(@Parameter("userId") Long id, String userName);
}
\ No newline at end of file
diff --git a/src/test/java/com/github/jaemon/dinger/httpclient/HttpClientTemplate.java b/src/test/java/com/github/jaemon/dinger/httpclient/HttpClientTemplate.java
index 81e8f45..ec3c524 100644
--- a/src/test/java/com/github/jaemon/dinger/httpclient/HttpClientTemplate.java
+++ b/src/test/java/com/github/jaemon/dinger/httpclient/HttpClientTemplate.java
@@ -28,7 +28,7 @@
* HttpClientTemplate
*
* @author Jaemon
- * @since 4.0
+ * @since 1.0
*/
public class HttpClientTemplate {
public static void main(String[] args) {
diff --git a/src/test/java/com/github/jaemon/dinger/multi/DingerHandlerTest.java b/src/test/java/com/github/jaemon/dinger/multi/DingerHandlerTest.java
index 788c364..7412eb6 100644
--- a/src/test/java/com/github/jaemon/dinger/multi/DingerHandlerTest.java
+++ b/src/test/java/com/github/jaemon/dinger/multi/DingerHandlerTest.java
@@ -33,7 +33,7 @@
* Dinger钉钉机器人算法-测试用例 {@link DingerHandler}
*
* @author Jaemon
- * @since 3.0
+ * @since 1.0
*/
public class DingerHandlerTest {
@@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception {
List dingerConfigs = new ArrayList<>();
for (int i = 0; i < 5; i++) {
- DingerConfig dingerConfig = new DingerConfig(uuid());
+ DingerConfig dingerConfig = DingerConfig.instance(uuid());
dingerConfigs.add(dingerConfig);
}
System.out.println(objectMapper.writeValueAsString(
diff --git a/src/test/java/com/github/jaemon/dinger/multi/RoundRobinHandlerTest.java b/src/test/java/com/github/jaemon/dinger/multi/RoundRobinHandlerTest.java
index d30311e..ad6cb84 100644
--- a/src/test/java/com/github/jaemon/dinger/multi/RoundRobinHandlerTest.java
+++ b/src/test/java/com/github/jaemon/dinger/multi/RoundRobinHandlerTest.java
@@ -35,7 +35,7 @@
* 轮询算法-测试用例 {@link RoundRobinHandler}
*
* @author Jaemon
- * @since 3.0
+ * @since 1.0
*/
public class RoundRobinHandlerTest {
@@ -47,7 +47,7 @@ public static void main(String[] args) throws Exception {
List dingerConfigs = new ArrayList<>();
for (int i = 0; i < 5; i++) {
- DingerConfig dingerConfig = new DingerConfig(uuid());
+ DingerConfig dingerConfig = DingerConfig.instance(uuid());
dingerConfigs.add(dingerConfig);
}
System.out.println(objectMapper.writeValueAsString(
diff --git a/src/test/java/com/github/jaemon/dinger/multi/handler/UserDingerConfigHandler.java b/src/test/java/com/github/jaemon/dinger/multi/handler/UserDingerConfigHandler.java
index 93ed6e7..3ed7460 100644
--- a/src/test/java/com/github/jaemon/dinger/multi/handler/UserDingerConfigHandler.java
+++ b/src/test/java/com/github/jaemon/dinger/multi/handler/UserDingerConfigHandler.java
@@ -15,7 +15,6 @@
*/
package com.github.jaemon.dinger.multi.handler;
-import com.github.jaemon.dinger.core.entity.enums.DingerType;
import com.github.jaemon.dinger.multi.DingerConfigHandler;
import com.github.jaemon.dinger.multi.algorithm.AlgorithmHandler;
import com.github.jaemon.dinger.multi.algorithm.DingerHandler;
@@ -28,19 +27,14 @@
* UserDingerConfigHandler
*
* @author Jaemon
- * @since 3.0
+ * @since 1.0
*/
public class UserDingerConfigHandler implements DingerConfigHandler {
- @Override
- public DingerType dinger() {
- return DingerType.DINGTALK;
- }
-
@Override
public List dingerConfigs() {
ArrayList dingerConfigs = new ArrayList<>();
- dingerConfigs.add(new DingerConfig("tokenId1", "secret1"));
- dingerConfigs.add(new DingerConfig("tokenId2", "secret2"));
+ dingerConfigs.add(DingerConfig.instance("tokenId1", "secret1"));
+ dingerConfigs.add(DingerConfig.instance("tokenId2", "secret2"));
// 如需配置更多机器人信息,可继续添加...
return dingerConfigs;
}