Skip to content

Commit

Permalink
fix: 潜在bug修复及优化
Browse files Browse the repository at this point in the history
  • Loading branch information
AnswerAIL committed Dec 27, 2020
1 parent 9f7accd commit 55c61a5
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.github.answerail</groupId>
<artifactId>dinger-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>1.0.1</version>

<name>dinger-spring-boot-starter</name>
<description>Dinger-SpringBoot集成钉钉/企业微信群机器人实现消息通知中间件</description>
Expand Down
165 changes: 164 additions & 1 deletion src/main/java/com/github/jaemon/dinger/core/DingerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ private DingerConfig(String tokenId, String secret) {
this.secret = secret;
}

private DingerConfig(String tokenId, String secret, boolean async) {
this.tokenId = tokenId;
this.secret = secret;
this.asyncExecute = async;
}

private DingerConfig(DingerType dingerType, String tokenId, String secret, boolean async) {
this(tokenId, secret, async);
this.dingerType = dingerType;
}

private DingerConfig(DingerType dingerType, String tokenId, String secret) {
this(tokenId, secret);
this.dingerType = dingerType;
Expand Down Expand Up @@ -93,42 +104,194 @@ private DingerConfig(DingerType dingerType, String tokenId, String secret, Strin
this.dingerType = dingerType;
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId) {
return new DingerConfig(tokenId);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId) {
return new DingerConfig(dingerType, tokenId);
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId, String secret) {
return new DingerConfig(tokenId, secret);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId, String secret) {
return new DingerConfig(dingerType, tokenId, secret);
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId, boolean asyncExecute) {
return new DingerConfig(tokenId, asyncExecute);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId, boolean asyncExecute) {
return new DingerConfig(dingerType, tokenId, asyncExecute);
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId, String secret, boolean asyncExecute) {
return new DingerConfig(tokenId, secret, asyncExecute);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId, String secret, boolean asyncExecute) {
return new DingerConfig(dingerType, tokenId, secret, asyncExecute);
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param decryptKey
* Dinger组件内部解密秘钥
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId, String secret, String decryptKey) {
return new DingerConfig(tokenId, secret, decryptKey);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param decryptKey
* Dinger组件内部解密秘钥
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId, String secret, String decryptKey) {
return new DingerConfig(dingerType, tokenId, secret, decryptKey);
}

/**
* Dinger机器人配置实例
*
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param decryptKey
* Dinger组件内部解密秘钥
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(String tokenId, String secret, String decryptKey, boolean asyncExecute) {
return new DingerConfig(tokenId, secret, decryptKey, asyncExecute);
}

/**
* Dinger机器人配置实例
*
* @param dingerType
* Dinger机器人类型, {@link DingerType}, MultiDinger中无需指定
* @param tokenId
* 机器人tokenID
* @param secret
* 机器人签名秘钥
* @param decryptKey
* Dinger组件内部解密秘钥
* @param asyncExecute
* 是否异步发送
* @return
* 机器人配置实例
*/
public static DingerConfig instance(DingerType dingerType, String tokenId, String secret, String decryptKey, boolean asyncExecute) {
return new DingerConfig(dingerType, tokenId, secret, decryptKey, asyncExecute);
}
Expand Down Expand Up @@ -222,7 +385,7 @@ public void setSecret(String secret) {
}

public Boolean getAsyncExecute() {
return asyncExecute;
return asyncExecute == null ? false : asyncExecute;
}

public void setAsyncExecute(Boolean asyncExecute) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl

DingerType useDinger = dingerType(method);
DingerDefinition dingerDefinition = dingerDefinition(
useDinger, keyName
useDinger, dingerClassName, keyName
);
if (dingerDefinition == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ DingerType dingerType(Method method) {
*
* @param useDinger
* 代理方法使用的Dinger
* @param dingerClassName
* 代理类全限定名
* @param keyName
* keyName
* 代理方法全限定名
* @return
* dingerDefinition {@link DingerDefinition}
*/
DingerDefinition dingerDefinition(DingerType useDinger, String keyName) {
DingerDefinition dingerDefinition(DingerType useDinger, String dingerClassName, String keyName) {
DingerDefinition dingerDefinition;
DingerConfig localDinger = DingerHelper.getLocalDinger();

Expand All @@ -173,7 +175,7 @@ DingerDefinition dingerDefinition(DingerType useDinger, String keyName) {
if (multiDinger()) {
MultiDingerConfig multiDingerConfig =
MultiDingerConfigContainer
.INSTANCE.get(useDinger, keyName);
.INSTANCE.get(useDinger, dingerClassName);
DingerConfig dingerConfig = null;
if (multiDingerConfig != null) {
// 拿到MultiDingerConfig中当前应该使用的DingerConfig
Expand Down

0 comments on commit 55c61a5

Please sign in to comment.