diff --git a/pom.xml b/pom.xml
index 22861b1..210279e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,6 +79,11 @@
commons-io
${commons-io.version}
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.4
+
@@ -86,18 +91,6 @@
fastjson
${fastjson-lib.version}
-
- com.google.code.gson
- gson
- ${gson.version}
-
-
-
- net.sf.json-lib
- json-lib
- ${json-lib.version}
- jdk15
-
org.slf4j
diff --git a/src/main/java/com/jeecg/qywx/api/conversation/ConversationAPI.java b/src/main/java/com/jeecg/qywx/api/conversation/ConversationAPI.java
index 65c80bb..3526317 100644
--- a/src/main/java/com/jeecg/qywx/api/conversation/ConversationAPI.java
+++ b/src/main/java/com/jeecg/qywx/api/conversation/ConversationAPI.java
@@ -1,23 +1,17 @@
package com.jeecg.qywx.api.conversation;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.jeecg.qywx.api.base.JwAccessTokenAPI;
-import com.jeecg.qywx.api.base.JwParamesAPI;
import com.jeecg.qywx.api.conversation.vo.BaseMessage;
import com.jeecg.qywx.api.conversation.vo.Conversation;
import com.jeecg.qywx.api.conversation.vo.Conversation4Update;
import com.jeecg.qywx.api.conversation.vo.Mute;
-import com.jeecg.qywx.api.core.common.AccessToken;
import com.jeecg.qywx.api.core.common.MsgResponse;
import com.jeecg.qywx.api.core.util.HttpUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
/**
*
* @author SunHaiFeng
diff --git a/src/main/java/com/jeecg/qywx/api/core/util/WXUpload.java b/src/main/java/com/jeecg/qywx/api/core/util/WXUpload.java
index 8a59f91..7a9afa0 100644
--- a/src/main/java/com/jeecg/qywx/api/core/util/WXUpload.java
+++ b/src/main/java/com/jeecg/qywx/api/core/util/WXUpload.java
@@ -1,24 +1,15 @@
package com.jeecg.qywx.api.core.util;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import org.apache.commons.lang.StringUtils;
-
import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.qywx.api.base.JwAccessTokenAPI;
import com.jeecg.qywx.api.base.JwParamesAPI;
import com.jeecg.qywx.api.core.common.AccessToken;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
public class WXUpload {
private static final String upload_wechat_url = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE";
/**
@@ -154,10 +145,10 @@ public static String getFileName(String fileUrl,String contentType) {
public static void writeFile(byte[] data, String dir, String filename,
boolean cover) {
try {
- if (StringUtils.isBlank(dir)) {
+ if (StringUtils.isEmpty(dir)) {
throw new Exception("目录不能为空");
}
- if (StringUtils.isBlank(filename)) {
+ if (StringUtils.isEmpty(filename)) {
throw new Exception("文件名称不能为空");
}
File dirfile = new File(dir);
diff --git a/src/main/java/com/jeecg/qywx/api/department/JwDepartmentAPI.java b/src/main/java/com/jeecg/qywx/api/department/JwDepartmentAPI.java
index 6ad340b..b5c1c0f 100644
--- a/src/main/java/com/jeecg/qywx/api/department/JwDepartmentAPI.java
+++ b/src/main/java/com/jeecg/qywx/api/department/JwDepartmentAPI.java
@@ -1,11 +1,11 @@
package com.jeecg.qywx.api.department;
import java.util.List;
+
+import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
import com.jeecg.qywx.api.base.JwAccessTokenAPI;
import com.jeecg.qywx.api.base.JwParamesAPI;
import com.jeecg.qywx.api.core.common.AccessToken;
@@ -97,8 +97,8 @@ public static List getAllDepartment(String accessToken) {
int errcode = jsonObject.getIntValue("errcode");
String errmsg = jsonObject.getString("errmsg");
String departmentjson = jsonObject.getString("department");
- Gson gson = new Gson();
- List ps = gson.fromJson(departmentjson, new TypeToken>(){}.getType());
+
+ List ps = JSON.parseArray(departmentjson, Department.class);
return ps;
}
return null;
diff --git a/src/main/java/com/jeecg/weibo/api/WeiboAccountApi.java b/src/main/java/com/jeecg/weibo/api/WeiboAccountApi.java
index cc73c9d..3a64331 100644
--- a/src/main/java/com/jeecg/weibo/api/WeiboAccountApi.java
+++ b/src/main/java/com/jeecg/weibo/api/WeiboAccountApi.java
@@ -1,6 +1,6 @@
package com.jeecg.weibo.api;
-import org.apache.commons.lang.StringUtils;
+import com.alipay.api.internal.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/jeecg/weibo/api/WeiboSendApi.java b/src/main/java/com/jeecg/weibo/api/WeiboSendApi.java
index 9aaaa3a..72a5988 100644
--- a/src/main/java/com/jeecg/weibo/api/WeiboSendApi.java
+++ b/src/main/java/com/jeecg/weibo/api/WeiboSendApi.java
@@ -1,6 +1,6 @@
package com.jeecg.weibo.api;
-import org.apache.commons.lang.StringUtils;
+import com.alipay.api.internal.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/jeecg/weibo/dto/WeiboSendDto.java b/src/main/java/com/jeecg/weibo/dto/WeiboSendDto.java
index ded51b5..88b2df8 100644
--- a/src/main/java/com/jeecg/weibo/dto/WeiboSendDto.java
+++ b/src/main/java/com/jeecg/weibo/dto/WeiboSendDto.java
@@ -1,8 +1,8 @@
package com.jeecg.weibo.dto;
-import java.net.URLEncoder;
+import com.alipay.api.internal.util.StringUtils;
-import org.apache.commons.lang.StringUtils;
+import java.net.URLEncoder;
/**
* 发布微博
@@ -27,7 +27,7 @@ public void setAccess_token(String access_token) {
}
public String getStatus() {
String encode = "";
- if(StringUtils.isNotEmpty(status)){
+ if(!StringUtils.isEmpty(status)){
encode = URLEncoder.encode(status);
}
return encode;
diff --git a/src/main/java/com/jeecg/weibo/util/WeiboCommentsUtil.java b/src/main/java/com/jeecg/weibo/util/WeiboCommentsUtil.java
index 9f49c80..adf24f4 100644
--- a/src/main/java/com/jeecg/weibo/util/WeiboCommentsUtil.java
+++ b/src/main/java/com/jeecg/weibo/util/WeiboCommentsUtil.java
@@ -1,7 +1,6 @@
package com.jeecg.weibo.util;
-import org.apache.commons.lang.StringUtils;
-
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.weibo.dto.WeiBoMentionsDto;
import com.jeecg.weibo.exception.BusinessException;
@@ -23,22 +22,22 @@ public static void getBymeParmValidate(WeiBoMentionsDto mentions){
public static String getBymeUrl (String interUrl,WeiBoMentionsDto mentions){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(mentions.getAccess_token())){
+ if(!StringUtils.isEmpty(mentions.getAccess_token())){
requestUrl.append("&access_token="+mentions.getAccess_token());
}
- if(StringUtils.isNotEmpty(mentions.getSince_id())){
+ if(!StringUtils.isEmpty(mentions.getSince_id())){
requestUrl.append("&since_id="+mentions.getSince_id());
}
- if(StringUtils.isNotEmpty(mentions.getMax_id())){
+ if(!StringUtils.isEmpty(mentions.getMax_id())){
requestUrl.append("&max_id="+mentions.getMax_id());
}
- if(StringUtils.isNotEmpty(mentions.getCount())){
+ if(!StringUtils.isEmpty(mentions.getCount())){
requestUrl.append("&count="+mentions.getCount());
}
- if(StringUtils.isNotEmpty(mentions.getPage())){
+ if(!StringUtils.isEmpty(mentions.getPage())){
requestUrl.append("&page="+mentions.getPage());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_source())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_source())){
requestUrl.append("&filter_by_source="+mentions.getFilter_by_source());
}
return requestUrl.toString();
@@ -50,25 +49,25 @@ public static String getBymeUrl (String interUrl,WeiBoMentionsDto mentions){
public static String getTomeUrl (String interUrl,WeiBoMentionsDto mentions){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(mentions.getAccess_token())){
+ if(!StringUtils.isEmpty(mentions.getAccess_token())){
requestUrl.append("&access_token="+mentions.getAccess_token());
}
- if(StringUtils.isNotEmpty(mentions.getSince_id())){
+ if(!StringUtils.isEmpty(mentions.getSince_id())){
requestUrl.append("&since_id="+mentions.getSince_id());
}
- if(StringUtils.isNotEmpty(mentions.getMax_id())){
+ if(!StringUtils.isEmpty(mentions.getMax_id())){
requestUrl.append("&max_id="+mentions.getMax_id());
}
- if(StringUtils.isNotEmpty(mentions.getCount())){
+ if(!StringUtils.isEmpty(mentions.getCount())){
requestUrl.append("&count="+mentions.getCount());
}
- if(StringUtils.isNotEmpty(mentions.getPage())){
+ if(!StringUtils.isEmpty(mentions.getPage())){
requestUrl.append("&page="+mentions.getPage());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_author())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_author())){
requestUrl.append("&filter_by_author="+mentions.getFilter_by_author());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_source())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_source())){
requestUrl.append("&filter_by_source="+mentions.getFilter_by_source());
}
return requestUrl.toString();
diff --git a/src/main/java/com/jeecg/weibo/util/WeiboFollowersUtil.java b/src/main/java/com/jeecg/weibo/util/WeiboFollowersUtil.java
index e4d62f6..50da309 100644
--- a/src/main/java/com/jeecg/weibo/util/WeiboFollowersUtil.java
+++ b/src/main/java/com/jeecg/weibo/util/WeiboFollowersUtil.java
@@ -1,6 +1,6 @@
package com.jeecg.weibo.util;
-import org.apache.commons.lang.StringUtils;
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.weibo.dto.WeiboFollowersDto;
import com.jeecg.weibo.exception.BusinessException;
@@ -26,22 +26,22 @@ public static void getFollowersParmValidate(WeiboFollowersDto followers){
public static String getFollowersUrl (String interUrl,WeiboFollowersDto followers){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(followers.getAccess_token())){
+ if(!StringUtils.isEmpty(followers.getAccess_token())){
requestUrl.append("&access_token="+followers.getAccess_token());
}
- if(StringUtils.isNotEmpty(followers.getUid())){
+ if(!StringUtils.isEmpty(followers.getUid())){
requestUrl.append("&uid="+followers.getUid());
}
- if(StringUtils.isNotEmpty(followers.getScreen_name())){
+ if(!StringUtils.isEmpty(followers.getScreen_name())){
requestUrl.append("&screen_name="+followers.getScreen_name());
}
- if(StringUtils.isNotEmpty(followers.getCount())){
+ if(!StringUtils.isEmpty(followers.getCount())){
requestUrl.append("&count="+followers.getCount());
}
- if(StringUtils.isNotEmpty(followers.getCursor())){
+ if(!StringUtils.isEmpty(followers.getCursor())){
requestUrl.append("&cursor="+followers.getCursor());
}
- if(StringUtils.isNotEmpty(followers.getTrim_status())){
+ if(!StringUtils.isEmpty(followers.getTrim_status())){
requestUrl.append("&trim_status="+followers.getTrim_status());
}
return requestUrl.toString();
@@ -63,19 +63,19 @@ public static void getFollowersIdsParmValidate(WeiboFollowersDto followers){
public static String getFollowersIdsUrl(String interUrl,WeiboFollowersDto followers){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(followers.getAccess_token())){
+ if(!StringUtils.isEmpty(followers.getAccess_token())){
requestUrl.append("&access_token="+followers.getAccess_token());
}
- if(StringUtils.isNotEmpty(followers.getUid())){
+ if(!StringUtils.isEmpty(followers.getUid())){
requestUrl.append("&uid="+followers.getUid());
}
- if(StringUtils.isNotEmpty(followers.getScreen_name())){
+ if(!StringUtils.isEmpty(followers.getScreen_name())){
requestUrl.append("&screen_name="+followers.getScreen_name());
}
- if(StringUtils.isNotEmpty(followers.getCount())){
+ if(!StringUtils.isEmpty(followers.getCount())){
requestUrl.append("&count="+followers.getCount());
}
- if(StringUtils.isNotEmpty(followers.getCursor())){
+ if(!StringUtils.isEmpty(followers.getCursor())){
requestUrl.append("&cursor="+followers.getCursor());
}
return requestUrl.toString();
diff --git a/src/main/java/com/jeecg/weibo/util/WeiboSendUtil.java b/src/main/java/com/jeecg/weibo/util/WeiboSendUtil.java
index 69dbb9e..1de3a69 100644
--- a/src/main/java/com/jeecg/weibo/util/WeiboSendUtil.java
+++ b/src/main/java/com/jeecg/weibo/util/WeiboSendUtil.java
@@ -2,7 +2,7 @@
import java.net.URLEncoder;
-import org.apache.commons.lang.StringUtils;
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.weibo.dto.WeiboSendDto;
import com.jeecg.weibo.exception.BusinessException;
@@ -29,13 +29,13 @@ public static void getSendParmValidate(WeiboSendDto send){
public static String getSendUrl (String interUrl,WeiboSendDto send){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(send.getAccess_token())){
+ if(!StringUtils.isEmpty(send.getAccess_token())){
requestUrl.append("&access_token="+send.getAccess_token());
}
- if(StringUtils.isNotEmpty(send.getStatus())){
+ if(!StringUtils.isEmpty(send.getStatus())){
requestUrl.append("&status="+send.getStatus());
}
- if(StringUtils.isNotEmpty(send.getUrl())){
+ if(!StringUtils.isEmpty(send.getUrl())){
String url = URLEncoder.encode(send.getUrl());
requestUrl.append("&url="+url);
}
@@ -55,10 +55,10 @@ public static void delParmValidate(WeiboSendDto send){
public static String getDelUrl (String interUrl,WeiboSendDto send){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(send.getAccess_token())){
+ if(!StringUtils.isEmpty(send.getAccess_token())){
requestUrl.append("&access_token="+send.getAccess_token());
}
- if(StringUtils.isNotEmpty(send.getId())){
+ if(!StringUtils.isEmpty(send.getId())){
requestUrl.append("&id="+send.getId());
}
return requestUrl.toString();
diff --git a/src/main/java/com/jeecg/weibo/util/WeiboStatusesUtil.java b/src/main/java/com/jeecg/weibo/util/WeiboStatusesUtil.java
index 589b458..ef8522c 100644
--- a/src/main/java/com/jeecg/weibo/util/WeiboStatusesUtil.java
+++ b/src/main/java/com/jeecg/weibo/util/WeiboStatusesUtil.java
@@ -1,6 +1,6 @@
package com.jeecg.weibo.util;
-import org.apache.commons.lang.StringUtils;
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.weibo.dto.WeiBoMentionsDto;
import com.jeecg.weibo.dto.WeiboUserTimelineDto;
@@ -23,34 +23,34 @@ public static void getUserTimelineParmValidate (WeiboUserTimelineDto userTimelin
public static String getUserTimelineUrl (String interUrl,WeiboUserTimelineDto userTimeline){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(userTimeline.getAccess_token())){
+ if(!StringUtils.isEmpty(userTimeline.getAccess_token())){
requestUrl.append("&access_token="+userTimeline.getAccess_token());
}
- if(StringUtils.isNotEmpty(userTimeline.getUid())){
+ if(!StringUtils.isEmpty(userTimeline.getUid())){
requestUrl.append("&uid="+userTimeline.getUid());
}
- if(StringUtils.isNotEmpty(userTimeline.getScreen_name())){
+ if(!StringUtils.isEmpty(userTimeline.getScreen_name())){
requestUrl.append("&screen_name="+userTimeline.getScreen_name());
}
- if(StringUtils.isNotEmpty(userTimeline.getSince_id())){
+ if(!StringUtils.isEmpty(userTimeline.getSince_id())){
requestUrl.append("&since_id="+userTimeline.getSince_id());
}
- if(StringUtils.isNotEmpty(userTimeline.getMax_id())){
+ if(!StringUtils.isEmpty(userTimeline.getMax_id())){
requestUrl.append("&max_id="+userTimeline.getMax_id());
}
- if(StringUtils.isNotEmpty(userTimeline.getCount())){
+ if(!StringUtils.isEmpty(userTimeline.getCount())){
requestUrl.append("&count="+userTimeline.getCount());
}
- if(StringUtils.isNotEmpty(userTimeline.getPage())){
+ if(!StringUtils.isEmpty(userTimeline.getPage())){
requestUrl.append("&page="+userTimeline.getPage());
}
- if(StringUtils.isNotEmpty(userTimeline.getBase_app())){
+ if(!StringUtils.isEmpty(userTimeline.getBase_app())){
requestUrl.append("&base_app="+userTimeline.getBase_app());
}
- if(StringUtils.isNotEmpty(userTimeline.getFeature())){
+ if(!StringUtils.isEmpty(userTimeline.getFeature())){
requestUrl.append("&feature="+userTimeline.getFeature());
}
- if(StringUtils.isNotEmpty(userTimeline.getTrim_user())){
+ if(!StringUtils.isEmpty(userTimeline.getTrim_user())){
requestUrl.append("trim_user="+userTimeline.getTrim_user());
}
return requestUrl.toString();
@@ -66,7 +66,7 @@ public static void getUserTimelineIdsParmValidate (WeiboUserTimelineDto userTime
if(StringUtils.isEmpty(userTimeline.getUid())&&(StringUtils.isEmpty(userTimeline.getScreen_name()))){
throw new BusinessException("uid与screen_name二者不能全为空");
}
- if(StringUtils.isNotEmpty(userTimeline.getUid())&&(StringUtils.isNotEmpty(userTimeline.getScreen_name()))){
+ if(!StringUtils.isEmpty(userTimeline.getUid())&&(!StringUtils.isEmpty(userTimeline.getScreen_name()))){
throw new BusinessException("uid与screen_name二者只能选其一");
}
}
@@ -96,10 +96,10 @@ public static void getCountParmValidate(String access_token,String ids){
public static String getCountUrl (String interUrl,String access_token,String ids){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(access_token)){
+ if(!StringUtils.isEmpty(access_token)){
requestUrl.append("&access_token="+access_token);
}
- if(StringUtils.isNotEmpty(ids)){
+ if(!StringUtils.isEmpty(ids)){
requestUrl.append("&ids="+ids);
}
return requestUrl.toString();
@@ -128,10 +128,10 @@ public static void getShowParmValidate(String access_token,String id){
public static String getShowUrl (String interUrl,String access_token,String id){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(access_token)){
+ if(!StringUtils.isEmpty(access_token)){
requestUrl.append("&access_token="+access_token);
}
- if(StringUtils.isNotEmpty(id)){
+ if(!StringUtils.isEmpty(id)){
requestUrl.append("&id="+id);
}
return requestUrl.toString();
@@ -153,28 +153,28 @@ public static void getMentionsParmValidate(WeiBoMentionsDto mentions){
public static String getMentionsUrl (String interUrl,WeiBoMentionsDto mentions){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(mentions.getAccess_token())){
+ if(!StringUtils.isEmpty(mentions.getAccess_token())){
requestUrl.append("&access_token="+mentions.getAccess_token());
}
- if(StringUtils.isNotEmpty(mentions.getSince_id())){
+ if(!StringUtils.isEmpty(mentions.getSince_id())){
requestUrl.append("&since_id="+mentions.getSince_id());
}
- if(StringUtils.isNotEmpty(mentions.getMax_id())){
+ if(!StringUtils.isEmpty(mentions.getMax_id())){
requestUrl.append("&max_id="+mentions.getMax_id());
}
- if(StringUtils.isNotEmpty(mentions.getCount())){
+ if(!StringUtils.isEmpty(mentions.getCount())){
requestUrl.append("&count="+mentions.getCount());
}
- if(StringUtils.isNotEmpty(mentions.getPage())){
+ if(!StringUtils.isEmpty(mentions.getPage())){
requestUrl.append("&page="+mentions.getPage());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_author())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_author())){
requestUrl.append("&filter_by_author="+mentions.getFilter_by_author());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_source())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_source())){
requestUrl.append("&filter_by_source="+mentions.getFilter_by_source());
}
- if(StringUtils.isNotEmpty(mentions.getFilter_by_type())){
+ if(!StringUtils.isEmpty(mentions.getFilter_by_type())){
requestUrl.append("&filter_by_type="+mentions.getFilter_by_type());
}
return requestUrl.toString();
diff --git a/src/main/java/com/jeecg/weibo/util/WeiboUsersUtil.java b/src/main/java/com/jeecg/weibo/util/WeiboUsersUtil.java
index 58920bc..d12cd13 100644
--- a/src/main/java/com/jeecg/weibo/util/WeiboUsersUtil.java
+++ b/src/main/java/com/jeecg/weibo/util/WeiboUsersUtil.java
@@ -1,7 +1,6 @@
package com.jeecg.weibo.util;
-import org.apache.commons.lang.StringUtils;
-
+import com.alipay.api.internal.util.StringUtils;
import com.jeecg.weibo.exception.BusinessException;
public class WeiboUsersUtil {
@@ -17,7 +16,7 @@ public static void getShowParmValidate(String access_token,String uid,String scr
if(StringUtils.isEmpty(uid)&&StringUtils.isEmpty(screen_name)){
throw new BusinessException("uid与screen_name二者不能全为空");
}
- if(StringUtils.isNotEmpty(uid)&&StringUtils.isNotEmpty(screen_name)){
+ if(!StringUtils.isEmpty(uid)&&!StringUtils.isEmpty(screen_name)){
throw new BusinessException("uid与screen_name二者只能选其一");
}
}
@@ -28,13 +27,13 @@ public static void getShowParmValidate(String access_token,String uid,String scr
public static String getShowUrl (String interUrl,String access_token,String uid,String screen_name){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(access_token)){
+ if(!StringUtils.isEmpty(access_token)){
requestUrl.append("&access_token="+access_token);
}
- if(StringUtils.isNotEmpty(uid)){
+ if(!StringUtils.isEmpty(uid)){
requestUrl.append("&uid="+uid);
}
- if(StringUtils.isNotEmpty(screen_name)){
+ if(!StringUtils.isEmpty(screen_name)){
requestUrl.append("&screen_name="+screen_name);
}
return requestUrl.toString();
@@ -64,10 +63,10 @@ public static void getCountsParmValidate(String access_token,String uids){
public static String getCountsUrl (String interUrl,String access_token,String uids){
StringBuilder requestUrl=new StringBuilder();
requestUrl.append(interUrl);
- if(StringUtils.isNotEmpty(access_token)){
+ if(!StringUtils.isEmpty(access_token)){
requestUrl.append("&access_token="+access_token);
}
- if(StringUtils.isNotEmpty(uids)){
+ if(!StringUtils.isEmpty(uids)){
requestUrl.append("&uids="+uids);
}
return requestUrl.toString();
diff --git a/src/main/java/org/jeewx/api/ai/JwAIApi.java b/src/main/java/org/jeewx/api/ai/JwAIApi.java
index 62ba2b1..7ec6a79 100644
--- a/src/main/java/org/jeewx/api/ai/JwAIApi.java
+++ b/src/main/java/org/jeewx/api/ai/JwAIApi.java
@@ -12,13 +12,12 @@
import java.net.HttpURLConnection;
import java.net.URL;
+import com.alibaba.fastjson.JSONObject;
import org.jeewx.api.ai.model.Voice;
import org.jeewx.api.core.util.WeiXinConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import net.sf.json.JSONObject;
-
/**
* 微信--AI开放接口
*
@@ -174,7 +173,7 @@ private static JSONObject uploadVoice(Voice voice){
reader.close();
}
}
- jsonobject = JSONObject.fromObject(result);
+ jsonobject = JSONObject.parseObject(result);
} catch (Exception e) {
logger.info(e.getMessage());
e.printStackTrace();
@@ -266,7 +265,7 @@ private static JSONObject httpRequest(String requestUrl,
httpUrlConn.disconnect();
logger.info(buffer.toString());
//jsonObject = JSONObject.parseObject(buffer.toString());
- jsonObject = JSONObject.fromObject(buffer.toString());
+ jsonObject = JSONObject.parseObject(buffer.toString());
} catch (ConnectException ce) {
ce.printStackTrace();
logger
diff --git a/src/main/java/org/jeewx/api/core/common/AccessToken.java b/src/main/java/org/jeewx/api/core/common/AccessToken.java
index 6f4b3ad..ce60b5f 100644
--- a/src/main/java/org/jeewx/api/core/common/AccessToken.java
+++ b/src/main/java/org/jeewx/api/core/common/AccessToken.java
@@ -1,6 +1,6 @@
package org.jeewx.api.core.common;
-import net.sf.json.JSONObject;
+import com.alibaba.fastjson.JSONObject;
public class AccessToken {
diff --git a/src/main/java/org/jeewx/api/core/common/JSONHelper.java b/src/main/java/org/jeewx/api/core/common/JSONHelper.java
index 26171e9..a71ee23 100644
--- a/src/main/java/org/jeewx/api/core/common/JSONHelper.java
+++ b/src/main/java/org/jeewx/api/core/common/JSONHelper.java
@@ -6,8 +6,9 @@
import java.util.List;
import java.util.Map;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
@@ -21,73 +22,18 @@
public final class JSONHelper {
private static final Logger logger = LoggerFactory.getLogger(JSONHelper.class);
- // 将数组转换成JSON
- public static String array2json(Object object) {
- JSONArray jsonArray = JSONArray.fromObject(object);
- return jsonArray.toString();
- }
-
- // 将JSON转换成数组,其中valueClz为数组中存放的对象的Class
- public static Object json2Array(String json, Class valueClz) {
- JSONArray jsonArray = JSONArray.fromObject(json);
- return JSONArray.toArray(jsonArray, valueClz);
- }
-
- // 将Collection转换成JSON
- public static String collection2json(Object object) {
- JSONArray jsonArray = JSONArray.fromObject(object);
- return jsonArray.toString();
- }
-
- // 将Map转换成JSON
- public static String map2json(Object object) {
- JSONObject jsonObject = JSONObject.fromObject(object);
- return jsonObject.toString();
- }
-
- // 将JSON转换成Map,其中valueClz为Map中value的Class,keyArray为Map的key
- public static Map json2Map(Object[] keyArray, String json, Class valueClz) {
- JSONObject jsonObject = JSONObject.fromObject(json);
- Map classMap = new HashMap();
-
- for (int i = 0; i < keyArray.length; i++) {
- classMap.put(keyArray[i], valueClz);
- }
-
- return (Map) JSONObject.toBean(jsonObject, Map.class, classMap);
- }
// 将POJO转换成JSON
public static String bean2json(Object object) {
- JSONObject jsonObject = JSONObject.fromObject(object);
+ JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object));
return jsonObject.toString();
}
- // 将JSON转换成POJO,其中beanClz为POJO的Class
- public static Object json2Object(String json, Class beanClz) {
- return JSONObject.toBean(JSONObject.fromObject(json), beanClz);
- }
-
- // 将String转换成JSON
- public static String string2json(String key, String value) {
- JSONObject object = new JSONObject();
- object.put(key, value);
- return object.toString();
- }
-
- // 将JSON转换成String
- public static String json2String(String json, String key) {
- JSONObject jsonObject = JSONObject.fromObject(json);
- return jsonObject.get(key).toString();
- }
-
/***
* 将List对象序列化为JSON文本
*/
public static String toJSONString(List list) {
- JSONArray jsonArray = JSONArray.fromObject(list);
-
- return jsonArray.toString();
+ return JSON.toJSONString(list);
}
/***
@@ -97,9 +43,7 @@ public static String toJSONString(List list) {
* @return
*/
public static String toJSONString(Object object) {
- JSONArray jsonArray = JSONArray.fromObject(object);
-
- return jsonArray.toString();
+ return JSON.toJSONString(object);
}
/***
@@ -122,54 +66,6 @@ public static String toJSONString(JSONObject jsonObject) {
return jsonObject.toString();
}
- /***
- * 将对象转换为List对象
- *
- * @param object
- * @return
- */
- public static List toArrayList(Object object) {
- List arrayList = new ArrayList();
-
- JSONArray jsonArray = JSONArray.fromObject(object);
-
- Iterator it = jsonArray.iterator();
- while (it.hasNext()) {
- JSONObject jsonObject = (JSONObject) it.next();
-
- Iterator keys = jsonObject.keys();
- while (keys.hasNext()) {
- Object key = keys.next();
- Object value = jsonObject.get(key);
- arrayList.add(value);
- }
- }
-
- return arrayList;
- }
-
- /* *//***
- * 将对象转换为Collection对象
- *
- * @param object
- * @return
- */
- /*
- * public static Collection toCollection(Object object) { JSONArray
- * jsonArray = JSONArray.fromObject(object);
- *
- * return JSONArray.toCollection(jsonArray); }
- */
-
- /***
- * 将对象转换为JSON对象数组
- *
- * @param object
- * @return
- */
- public static JSONArray toJSONArray(Object object) {
- return JSONArray.fromObject(object);
- }
/***
* 将对象转换为JSON对象
@@ -178,26 +74,7 @@ public static JSONArray toJSONArray(Object object) {
* @return
*/
public static JSONObject toJSONObject(Object object) {
- return JSONObject.fromObject(object);
- }
-
- /***
- * 将对象转换为HashMap
- *
- * @param object
- * @return
- */
- public static HashMap toHashMap(Object object) {
- HashMap data = new HashMap();
- JSONObject jsonObject = JSONHelper.toJSONObject(object);
- Iterator it = jsonObject.keys();
- while (it.hasNext()) {
- String key = String.valueOf(it.next());
- Object value = jsonObject.get(key);
- data.put(key, value);
- }
-
- return data;
+ return JSONObject.parseObject(JSON.toJSONString(object));
}
/***
@@ -209,11 +86,11 @@ public static HashMap toHashMap(Object object) {
// 返回非实体类型(Map)的List
public static List