big update:去除被动消息实体、commons包、dom4j包

This commit is contained in:
jinyu
2015-05-12 23:27:39 +08:00
parent 165f4b3bb8
commit 3d0c3e2c9c
84 changed files with 836 additions and 3287 deletions
@@ -10,7 +10,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.mime.content.ByteArrayBody;
import com.alibaba.fastjson.JSON;
@@ -30,6 +29,7 @@ import com.foxinmy.weixin4j.type.MediaType;
import com.foxinmy.weixin4j.util.ConfigUtil;
import com.foxinmy.weixin4j.util.FileUtil;
import com.foxinmy.weixin4j.util.IOUtil;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 媒体相关API
@@ -62,7 +62,7 @@ public class MediaApi extends QyApi {
*/
public String uploadMedia(File file) throws WeixinException, IOException {
String mediaTypeKey = IOUtil.getExtension(file.getName());
if (StringUtils.isBlank(mediaTypeKey)) {
if (StringUtil.isBlank(mediaTypeKey)) {
mediaTypeKey = FileUtil.getFileType(file);
}
MediaType mediaType = MediaType.getMediaType(mediaTypeKey);
@@ -237,7 +237,7 @@ public class MediaApi extends QyApi {
return true;
}
});
writer.write(StringUtils.join(column.values(), ","));
writer.write(StringUtil.join(column.values(), ','));
writer.write("\r\n");
}
String mediaId = uploadMedia(batchName,
@@ -3,8 +3,6 @@ package com.foxinmy.weixin4j.qy.api;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -16,6 +14,7 @@ import com.foxinmy.weixin4j.qy.model.User;
import com.foxinmy.weixin4j.qy.type.InviteType;
import com.foxinmy.weixin4j.qy.type.UserStatus;
import com.foxinmy.weixin4j.token.TokenHolder;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 成员API
@@ -282,7 +281,7 @@ public class UserApi extends QyApi {
throws WeixinException {
JSONObject obj = new JSONObject();
obj.put("userid", userId);
if (StringUtils.isBlank(tips)) {
if (StringUtil.isBlank(tips)) {
obj.put("invite_tips", tips);
}
String invite_user_uri = getRequestUri("invite_user_uri");
@@ -1,100 +0,0 @@
package com.foxinmy.weixin4j.qy.event;
import java.io.Serializable;
import com.foxinmy.weixin4j.message.event.EventMessage;
import com.foxinmy.weixin4j.qy.type.EventType;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* 异步任务事件完成通知
*
* @className BatchjobresultMessage
* @author jy
* @date 2015年3月31日
* @since JDK 1.7
* @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E4%BA%8B%E4%BB%B6#.E5.BC.82.E6.AD.A5.E4.BB.BB.E5.8A.A1.E5.AE.8C.E6.88.90.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81">异步任务事件完成通知</a>
*/
public class BatchjobresultMessage extends EventMessage {
private static final long serialVersionUID = 8014540441322209657L;
public BatchjobresultMessage() {
super(EventType.batch_job_result.name());
}
/**
* 任务信息
*/
@XStreamAlias("BatchJob")
private BatchJob batchJob;
public BatchJob getBatchJob() {
return batchJob;
}
/**
* 任务信息
*
* @className BatchJob
* @author jy
* @date 2015年4月1日
* @since JDK 1.7
* @see
*/
public static class BatchJob implements Serializable {
private static final long serialVersionUID = -7520032656787156391L;
/**
* 异步任务id,最大长度为64字符
*/
@XStreamAlias("JobId")
private String jobId;
/**
* 操作类型,字符串,目前分别有: 1. sync_user(增量更新成员) 2. replace_user(全量覆盖成员) 3.
* invite_user(邀请成员关注) 4. replace_party(全量覆盖部门)
*
* @see com.foxinmy.weixin4j.qy.type.BatchType
*/
@XStreamAlias("JobType")
private String jobType;
/**
* 返回码
*/
@XStreamAlias("ErrCode")
private String ErrCode;
/**
* 对返回码的文本描述内容
*/
@XStreamAlias("ErrMsg")
private String errMsg;
public String getJobId() {
return jobId;
}
public String getJobType() {
return jobType;
}
public String getErrCode() {
return ErrCode;
}
public String getErrMsg() {
return errMsg;
}
@Override
public String toString() {
return "[jobId=" + jobId + ", jobType=" + jobType + ", ErrCode="
+ ErrCode + ", errMsg=" + errMsg + "]";
}
}
@Override
public String toString() {
return "BatchjobresultMessage [batchJob=" + batchJob + ", "
+ super.toString() + "]";
}
}
@@ -1,41 +0,0 @@
package com.foxinmy.weixin4j.qy.event;
import com.foxinmy.weixin4j.message.event.EventMessage;
import com.foxinmy.weixin4j.qy.type.EventType;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* 用户进入应用的事件推送(企业号)本事件只有在应用的回调模式中打开上报开关时上报
*
* @className EnterAgentEventMessage
* @author jy
* @date 2014年12月28日
* @since JDK 1.7
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E4%BA%8B%E4%BB%B6#.E7.94.A8.E6.88.B7.E8.BF.9B.E5.85.A5.E5.BA.94.E7.94.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81"
* >用户进入应用的事件推送</a>
*/
public class EnterAgentEventMessage extends EventMessage {
private static final long serialVersionUID = 7675732524832500820L;
public EnterAgentEventMessage() {
super(EventType.enter_agent.name());
}
/**
* 事件KEY值,与自定义菜单接口中KEY值对应
*/
@XStreamAlias("EventKey")
private String eventKey;
public String getEventKey() {
return eventKey;
}
@Override
public String toString() {
return "EnterAgentEventMessage [eventKey=" + eventKey + ", "
+ super.toString() + "]";
}
}
@@ -1,28 +0,0 @@
package com.foxinmy.weixin4j.qy.event;
import com.foxinmy.weixin4j.message.event.EventMessage;
import com.foxinmy.weixin4j.type.EventType;
/**
* 关注/取消关注事件</br> <font color="red">包括直接关注与扫描关注</font>
*
* @className ScribeEventMessage
* @author jy.hu
* @date 2014年4月6日
* @since JDK 1.7
* @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E4%BA%8B%E4%BB%B6#.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8.2F.E5.8F.96.E6.B6.88.E5.85.B3.E6.B3.A8.E4.BA.8B.E4.BB.B6">成员关注/取消关注事件</a>
*/
public class ScribeEventMessage extends EventMessage {
private static final long serialVersionUID = -6846321620262204915L;
public ScribeEventMessage() {
super(EventType.subscribe.name());
}
@Override
public String toString() {
return "ScribeEventMessage [" + super.toString() + "]";
}
}
@@ -3,10 +3,9 @@ package com.foxinmy.weixin4j.qy.message;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.tuple.NotifyTuple;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 发送消息对象
@@ -29,7 +28,7 @@ public class NotifyMessage implements Serializable {
private static final long serialVersionUID = 1219589414293000383L;
private static final String SEPARATOR = "|";
private static final char SEPARATOR = '|';
/**
* UserID列表(消息接收者,多个接收者用‘|’分隔)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
@@ -65,13 +64,13 @@ public class NotifyMessage implements Serializable {
public NotifyMessage(List<String> tousers, List<String> topartys,
List<String> totags, NotifyTuple tuple, int agentid, boolean isSafe) {
if (tousers != null && !tousers.isEmpty()) {
this.touser = StringUtils.join(tousers, SEPARATOR);
this.touser = StringUtil.join(tousers, SEPARATOR);
}
if (topartys != null && !topartys.isEmpty()) {
this.toparty = StringUtils.join(topartys, SEPARATOR);
this.toparty = StringUtil.join(topartys, SEPARATOR);
}
if (totags != null && !totags.isEmpty()) {
this.totag = StringUtils.join(totags, SEPARATOR);
this.totag = StringUtil.join(totags, SEPARATOR);
}
this.agentid = agentid;
this.safe = isSafe ? 1 : 0;
@@ -88,7 +87,7 @@ public class NotifyMessage implements Serializable {
public void setTouser(List<String> tousers) {
if (tousers != null && !tousers.isEmpty()) {
this.touser = StringUtils.join(tousers, SEPARATOR);
this.touser = StringUtil.join(tousers, SEPARATOR);
}
}
@@ -102,7 +101,7 @@ public class NotifyMessage implements Serializable {
public void setToparty(List<String> topartys) {
if (topartys != null && !topartys.isEmpty()) {
this.toparty = StringUtils.join(topartys, SEPARATOR);
this.toparty = StringUtil.join(topartys, SEPARATOR);
}
}
@@ -116,7 +115,7 @@ public class NotifyMessage implements Serializable {
public void setTotag(List<String> totags) {
if (totags != null && !totags.isEmpty()) {
this.totag = StringUtils.join(totags, SEPARATOR);
this.totag = StringUtil.join(totags, SEPARATOR);
}
}
@@ -4,7 +4,7 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* id参数集
@@ -19,6 +19,8 @@ public class IdParameter implements Serializable {
private static final long serialVersionUID = -2689758682205591133L;
private static final char SEPARATOR = '|';
private Map<String, String> parameterMap;
public IdParameter() {
@@ -32,7 +34,7 @@ public class IdParameter implements Serializable {
* @return
*/
public IdParameter putUseIds(String... userIds) {
parameterMap.put("touser", StringUtils.join(userIds, '|'));
parameterMap.put("touser", StringUtil.join(userIds, SEPARATOR));
return this;
}
@@ -43,7 +45,7 @@ public class IdParameter implements Serializable {
* @return
*/
public IdParameter putUseIds(int... partyIds) {
parameterMap.put("toparty", StringUtils.join(partyIds, '|'));
parameterMap.put("toparty", StringUtil.join(partyIds, SEPARATOR));
return this;
}
@@ -54,7 +56,7 @@ public class IdParameter implements Serializable {
* @return
*/
public IdParameter putTagIds(int... tagIds) {
parameterMap.put("totag", StringUtils.join(tagIds, '|'));
parameterMap.put("totag", StringUtil.join(tagIds, SEPARATOR));
return this;
}
@@ -1,25 +0,0 @@
package com.foxinmy.weixin4j.qy.type;
/**
* 企业号事件类型
*
* @className EventType
* @author jy
* @date 2014年9月30日
* @since JDK 1.7
* @see
*/
public enum EventType {
/**
* 进入企业号应用事件
*
* @see com.foxinmy.weixin4j.qy.event.EnterAgentEventMessage
*/
enter_agent,
/**
* 异步任务完成事件
*
* @see com.foxinmy.weixin4j.msg.event.BatchjobresultMessage
*/
batch_job_result;
}