减少不必要的依赖项
This commit is contained in:
parent
605fee50dd
commit
3e0ac9fc2e
@ -0,0 +1,33 @@
|
||||
package com.cicdi.notify.util;
|
||||
|
||||
/**
|
||||
* @author Yaser Hsueh
|
||||
*/
|
||||
public abstract class StringUtils {
|
||||
|
||||
public static boolean isEmpty(Object str) {
|
||||
return (str == null || "".equals(str));
|
||||
}
|
||||
|
||||
public static boolean hasLength(CharSequence str) {
|
||||
return (str != null && str.length() > 0);
|
||||
}
|
||||
|
||||
public static boolean hasLength(String str) {
|
||||
return (str != null && !str.isEmpty());
|
||||
}
|
||||
|
||||
public static boolean isBlank(String str) {
|
||||
int strLen;
|
||||
if (str == null || (strLen = str.length()) == 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
if ((!Character.isWhitespace(str.charAt(i)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -29,12 +29,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
|
@ -6,6 +6,7 @@ import com.cicdi.notify.email.EmailProvider;
|
||||
import com.cicdi.notify.email.EmailTemplate;
|
||||
import com.cicdi.notify.email.EmailTemplateParsed;
|
||||
import com.cicdi.notify.util.ExpressionUtils;
|
||||
import com.cicdi.notify.util.StringUtils;
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
@ -19,7 +20,6 @@ import org.springframework.core.io.InputStreamSource;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
@ -23,9 +23,7 @@ public class DefaultEmailTest {
|
||||
@Test
|
||||
public void testSend() {
|
||||
// 通知器配置管理器
|
||||
NotifyConfigManager notifyConfigManager = new NotifyConfigManager() {
|
||||
@Override
|
||||
public NotifierProperties getNotifyConfig(NotifyType notifyType, String configId) {
|
||||
NotifyConfigManager notifyConfigManager = (notifyType, configId) -> {
|
||||
NotifierProperties notifierProperties = new NotifierProperties();
|
||||
notifierProperties.setType(DefaultNotifyType.email.getId());
|
||||
notifierProperties.setProvider(EmailProvider.embedded.getId());
|
||||
@ -47,7 +45,6 @@ public class DefaultEmailTest {
|
||||
config.put("properties", Arrays.asList(p1, p2));
|
||||
notifierProperties.setConfiguration(config);
|
||||
return notifierProperties;
|
||||
}
|
||||
};
|
||||
|
||||
// 模板管理器
|
||||
|
@ -33,11 +33,6 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -2,7 +2,7 @@ package com.cicdi.notify.wechat.corp;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cicdi.notify.template.Template;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.cicdi.notify.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@ -68,10 +68,10 @@ public class WechatCorpTemplate implements Template {
|
||||
json.put("msgtype", "text");
|
||||
json.put("text", Collections.singletonMap("content", message));
|
||||
|
||||
if (StringUtils.isNotBlank(toUser)) {
|
||||
if (!StringUtils.isBlank(toUser)) {
|
||||
json.put("touser", this.createUserIdList(context));
|
||||
}
|
||||
if (StringUtils.isNotBlank(toParty)) {
|
||||
if (!StringUtils.isBlank(toParty)) {
|
||||
json.put("toparty", this.createDepartmentIdList(context));
|
||||
}
|
||||
|
||||
|
12
pom.xml
12
pom.xml
@ -76,12 +76,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
@ -118,6 +112,12 @@
|
||||
<version>1.6.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
Loading…
Reference in New Issue
Block a user