主要去掉了实体类中的字段上@JSONFiled上的deserialize=false属性和不合理的format方法

This commit is contained in:
jinyu
2015-08-07 15:21:02 +08:00
parent 418f63d501
commit 4d5a6b228b
61 changed files with 946 additions and 760 deletions
@@ -155,7 +155,7 @@ public class BatchApi extends QyApi {
*
* @param jobId
* 任务ID
* @return 效果信息
* @return 执行结果对象
* @see com.foxinmy.weixin4j.qy.model.BatchResult
* @see <a
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E8.8E.B7.E5.8F.96.E5.BC.82.E6.AD.A5.E4.BB.BB.E5.8A.A1.E7.BB.93.E6.9E.9C">获取异步任务执行结果</a>
@@ -164,8 +164,8 @@ public class BatchApi extends QyApi {
public BatchResult getBatchResult(String jobId) throws WeixinException {
Token token = tokenHolder.getToken();
String batch_getresult_uri = getRequestUri("batch_getresult_uri");
WeixinResponse response = weixinClient.get(String.format(batch_getresult_uri,
token.getAccessToken(), jobId));
WeixinResponse response = weixinClient.get(String.format(
batch_getresult_uri, token.getAccessToken(), jobId));
return response.getAsObject(new TypeReference<BatchResult>() {
});
}
@@ -70,7 +70,7 @@ public class PartyApi extends QyApi {
}
String department_update_uri = getRequestUri("department_update_uri");
JSONObject obj = (JSONObject) JSON.toJSON(party);
if (party.getParentid() < 1) {
if (party.getParentId() < 1) {
obj.remove("parentid");
}
if (party.getOrder() < 0) {
@@ -118,6 +118,8 @@ public class UserApi extends QyApi {
}
if (avatar != null) {
obj.put("avatar_mediaid", mediaApi.uploadMedia(0, avatar, null));
} else {
obj.put("avatar_mediaid", obj.remove("avatar"));
}
Token token = tokenHolder.getToken();
WeixinResponse response = weixinClient.post(
@@ -2,6 +2,8 @@ package com.foxinmy.weixin4j.qy.message;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.qy.type.ChatType;
import com.foxinmy.weixin4j.tuple.ChatTuple;
@@ -37,8 +39,11 @@ public class ChatMessage implements Serializable {
*/
private ChatTuple chatTuple;
public ChatMessage(String targetId, ChatType chatType, String senderId,
ChatTuple chatTuple) {
@JSONCreator
public ChatMessage(@JSONField(name = "targetId") String targetId,
@JSONField(name = "chatType") ChatType chatType,
@JSONField(name = "senderId") String senderId,
@JSONField(name = "chatTuple") ChatTuple chatTuple) {
this.targetId = targetId;
this.chatType = chatType;
this.senderId = senderId;
@@ -30,7 +30,8 @@ public class NotifyMessage implements Serializable {
/**
* 企业应用的id,整型。可在应用的设置页面查看
*/
private int agentid;
@JSONField(name = "agentid")
private int agentId;
/**
* 表示是否是保密消息,0表示否,1表示是,默认0
*/
@@ -50,9 +51,9 @@ public class NotifyMessage implements Serializable {
this(agentid, tuple, IdParameter.get(), false);
}
public NotifyMessage(int agentid, NotifyTuple tuple, IdParameter target,
public NotifyMessage(int agentId, NotifyTuple tuple, IdParameter target,
boolean isSafe) {
this.agentid = agentid;
this.agentId = agentId;
this.safe = isSafe ? 1 : 0;
this.tuple = tuple;
this.target = target;
@@ -66,8 +67,8 @@ public class NotifyMessage implements Serializable {
this.safe = isSafe ? 1 : 0;
}
public int getAgentid() {
return agentid;
public int getAgentId() {
return agentId;
}
public NotifyTuple getTuple() {
@@ -80,7 +81,7 @@ public class NotifyMessage implements Serializable {
@Override
public String toString() {
return "NotifyMessage [agentid=" + agentid + ", safe=" + safe
return "NotifyMessage [agentId=" + agentId + ", safe=" + safe
+ ", tuple=" + tuple + ", target=" + target + "]";
}
}
@@ -30,17 +30,17 @@ public class AgentInfo extends AgentSetter {
/**
* 企业应用可见范围(人员),其中包括userid和关注状态state
*/
@JSONField(serialize = false)
@JSONField(deserialize = false)
private List<User> allowUsers;
/**
* 企业应用可见范围(部门)
*/
@JSONField(serialize = false)
@JSONField(deserialize = false)
private List<Integer> allowPartys;
/**
* 企业应用可见范围(标签)
*/
@JSONField(serialize = false)
@JSONField(deserialize = false)
private List<Integer> allowTags;
/**
* 企业应用是否被禁用
@@ -55,18 +55,10 @@ public class AgentInfo extends AgentSetter {
return squareLogoUrl;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public String getRoundLogoUrl() {
return roundLogoUrl;
}
public void setRoundLogoUrl(String roundLogoUrl) {
this.roundLogoUrl = roundLogoUrl;
}
public List<User> getAllowUsers() {
return allowUsers;
}
@@ -95,6 +87,16 @@ public class AgentInfo extends AgentSetter {
return close;
}
// ---------- setter 应该全部去掉
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public void setRoundLogoUrl(String roundLogoUrl) {
this.roundLogoUrl = roundLogoUrl;
}
public void setClose(boolean close) {
this.close = close;
}
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.annotation.JSONField;
/**
* 企业号应用的概况信息
*
* @className AgentOverview
* @author jy
* @date 2015年4月9日
@@ -13,12 +14,13 @@ import com.alibaba.fastjson.annotation.JSONField;
* @see
*/
public class AgentOverview implements Serializable {
private static final long serialVersionUID = 5459274811502476460L;
/**
* 企业应用的id
*/
private int agentid;
@JSONField(name = "agentid")
private int agentId;
/**
* 企业应用名称
*/
@@ -33,34 +35,43 @@ public class AgentOverview implements Serializable {
*/
@JSONField(name = "round_logo_url")
private String roundLogoUrl;
public int getAgentid() {
return agentid;
}
public void setAgentid(int agentid) {
this.agentid = agentid;
public int getAgentId() {
return agentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSquareLogoUrl() {
return squareLogoUrl;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public String getRoundLogoUrl() {
return roundLogoUrl;
}
// ---------- setter 应该全部去掉
public void setAgentId(int agentId) {
this.agentId = agentId;
}
public void setName(String name) {
this.name = name;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public void setRoundLogoUrl(String roundLogoUrl) {
this.roundLogoUrl = roundLogoUrl;
}
@Override
public String toString() {
return "AgentOverview [agentid=" + agentid + ", name=" + name
return "AgentOverview [agentId=" + agentId + ", name=" + name
+ ", squareLogoUrl=" + squareLogoUrl + ", roundLogoUrl="
+ roundLogoUrl + "]";
}
@@ -21,17 +21,18 @@ public class AgentSetter implements Serializable {
/**
* 企业应用的id
*/
private int agentid;
@JSONField(name = "agentid")
private int agentId;
/**
* 企业应用是否打开地理位置上报
*/
@JSONField(name = "report_location_flag")
private ReportLocationType reportLocationType;
private String reportLocationType;
/**
* 企业应用头像的mediaid,通过多媒体接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像
*/
@JSONField(name = "logo_mediaid")
private String logoMediaid;
private String logoMediaId;
/**
* 企业应用名称
*/
@@ -56,32 +57,34 @@ public class AgentSetter implements Serializable {
@JSONField(name = "isreportenter")
private int isReportEnter;
public AgentSetter(int agentid) {
this.agentid = agentid;
public AgentSetter(int agentId) {
this.agentId = agentId;
}
public int getAgentid() {
return agentid;
public int getAgentId() {
return agentId;
}
public void setAgentid(int agentid) {
this.agentid = agentid;
}
public ReportLocationType getReportLocationType() {
public String getReportLocationType() {
return reportLocationType;
}
@JSONField(serialize = false)
public ReportLocationType getFormatReportLocationType() {
return reportLocationType != null ? ReportLocationType
.valueOf(reportLocationType.toUpperCase()) : null;
}
public void setReportLocationType(ReportLocationType reportLocationType) {
this.reportLocationType = reportLocationType;
this.reportLocationType = reportLocationType.name();
}
public String getLogoMediaid() {
return logoMediaid;
public String getLogoMediaId() {
return logoMediaId;
}
public void setLogoMediaid(String logoMediaid) {
this.logoMediaid = logoMediaid;
public void setLogoMediaid(String logoMediaId) {
this.logoMediaId = logoMediaId;
}
public String getName() {
@@ -124,10 +127,24 @@ public class AgentSetter implements Serializable {
this.isReportEnter = isReportEnter ? 1 : 0;
}
// ---------- setter 应该全部去掉
public void setAgentId(int agentId) {
this.agentId = agentId;
}
public void setReportLocationType(String reportLocationType) {
this.reportLocationType = reportLocationType;
}
public void setLogoMediaId(String logoMediaId) {
this.logoMediaId = logoMediaId;
}
@Override
public String toString() {
return "agentid=" + agentid + ", reportLocationType="
+ reportLocationType + ", logoMediaid=" + logoMediaid
return "agentId=" + agentId + ", reportLocationType="
+ reportLocationType + ", logoMediaId=" + logoMediaId
+ ", name=" + name + ", description=" + description
+ ", redirectDomain=" + redirectDomain + ", isReportUser="
+ isReportUser + ", isReportEnter=" + isReportEnter;
@@ -1,6 +1,7 @@
package com.foxinmy.weixin4j.qy.model;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.http.weixin.JsonResult;
import com.foxinmy.weixin4j.qy.type.BatchStatus;
import com.foxinmy.weixin4j.qy.type.BatchType;
@@ -32,68 +33,82 @@ public class BatchResult extends JsonResult {
/**
* 目前运行百分比,当任务完成时为100
*/
private int percentage;
@JSONField(name = "percentage")
private int percentAge;
/**
* 预估剩余时间(单位:分钟),当任务完成时为0
*/
private int remaintime;
@JSONField(name = "remaintime")
private int remainTime;
/**
* 详细的处理结果 TODO
*/
private JSONArray result;
public BatchStatus getStatus() {
public int getStatus() {
return status;
}
@JSONField(serialize = false)
public BatchStatus getFormatStatus() {
return BatchStatus.values()[status - 1];
}
public void setStatus(int status) {
this.status = status;
public String getType() {
return type;
}
public BatchType getType() {
return BatchType.valueOf(type.toUpperCase());
}
public void setType(String type) {
this.type = type;
@JSONField(serialize = false)
public BatchType getFormatType() {
return type != null ? BatchType.valueOf(type.toUpperCase()) : null;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
public int getPercentAge() {
return percentAge;
}
public int getPercentage() {
return percentage;
}
public void setPercentage(int percentage) {
this.percentage = percentage;
}
public int getRemaintime() {
return remaintime;
}
public void setRemaintime(int remaintime) {
this.remaintime = remaintime;
public int getRemainTime() {
return remainTime;
}
public JSONArray getResult() {
return result;
}
// ---------- setter 应该全部去掉
public void setStatus(int status) {
this.status = status;
}
public void setType(String type) {
this.type = type;
}
public void setTotal(int total) {
this.total = total;
}
public void setPercentAge(int percentAge) {
this.percentAge = percentAge;
}
public void setRemainTime(int remainTime) {
this.remainTime = remainTime;
}
public void setResult(JSONArray result) {
this.result = result;
}
@Override
public String toString() {
return "BatchResult [status=" + getStatus() + ", type=" + getType() + ", total="
+ total + ", percentage=" + percentage + ", remaintime="
+ remaintime + ", result=" + result + "]";
return "BatchResult [status=" + status + ", type=" + type + ", total="
+ total + ", percentAge=" + percentAge + ", remainTime="
+ remainTime + ", result=" + result + "]";
}
}
@@ -3,7 +3,6 @@ package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
/**
@@ -37,19 +36,14 @@ public class ChatInfo implements Serializable {
@JSONField(name = "userlist")
private List<String> members;
public ChatInfo(String chatId, String name, String owner) {
this(chatId, name, owner, null);
public ChatInfo() {
}
@JSONCreator
public ChatInfo(@JSONField(name = "chatId") String chatId,
@JSONField(name = "name") String name,
@JSONField(name = "owner") String owner,
@JSONField(name = "userlist") List<String> members) {
public ChatInfo(String chatId, String name, String owner) {
this.chatId = chatId;
this.name = name;
this.owner = owner;
this.members = members;
}
public String getChatId() {
@@ -72,6 +66,20 @@ public class ChatInfo implements Serializable {
this.members = members;
}
// ---------- setter 应该全部去掉
public void setChatId(String chatId) {
this.chatId = chatId;
}
public void setName(String name) {
this.name = name;
}
public void setOwner(String owner) {
this.owner = owner;
}
@Override
public String toString() {
return "ChatInfo [chatId=" + chatId + ", name=" + name + ", owner="
@@ -2,6 +2,7 @@ package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
/**
@@ -17,7 +18,8 @@ public class ChatMute implements Serializable {
private static final long serialVersionUID = 6734443056426236273L;
private String userid;
@JSONField(name = "userid")
private String userId;
private int status;
/**
@@ -25,8 +27,8 @@ public class ChatMute implements Serializable {
*
* @param userid
*/
public ChatMute(String userid) {
this.userid = userid;
public ChatMute(String userId) {
this.userId = userId;
}
/**
@@ -37,27 +39,28 @@ public class ChatMute implements Serializable {
* @param status
* 是否开启免打扰
*/
public ChatMute(String userid, boolean status) {
this.userid = userid;
@JSONCreator
public ChatMute(@JSONField(name = "userId") String userId,
@JSONField(name = "status") boolean status) {
this.userId = userId;
this.status = status ? 1 : 0;
}
public String getUserid() {
return userid;
public String getUserId() {
return userId;
}
public int getStatus() {
return status;
}
@JSONField(deserialize = false)
@JSONField(serialize = false)
public boolean getFormatStatus() {
return status == 1;
}
@Override
public String toString() {
return "ChatMute [userid=" + userid + ", status=" + getFormatStatus()
+ "]";
return "ChatMute [userId=" + userId + ", status=" + status + "]";
}
}
@@ -8,19 +8,20 @@ import com.foxinmy.weixin4j.qy.type.CorpType;
/**
* 授权方企业号信息
*
* @className Corpinfo
* @className CorpInfo
* @author jy
* @date 2015年6月12日
* @since JDK 1.7
* @see
*/
public class Corpinfo implements Serializable {
public class CorpInfo implements Serializable {
private static final long serialVersionUID = 1251033124778972419L;
/**
* 授权方企业号id
*/
private String corpid;
@JSONField(name = "corpid")
private String corpId;
/**
* 授权方企业号名称
*/
@@ -40,93 +41,100 @@ public class Corpinfo implements Serializable {
* 授权方企业号类型
*/
@JSONField(name = "corp_type")
private CorpType corpType;
private String corpType;
/**
* 授权方企业号用户规模
*/
@JSONField(name = "corp_user_max")
private int userMax;
private Integer userMax;
/**
* 授权方企业号应用规模
*/
@JSONField(name = "corp_agent_max")
private int agentMax;
private Integer agentMax;
/**
* 授权方企业号二维码
*/
@JSONField(name = "corp_wxqrcode")
private String wxqrcode;
private String wxQrCode;
public String getCorpid() {
return corpid;
public String getCorpId() {
return corpId;
}
public void setCorpid(String corpid) {
this.corpid = corpid;
}
public CorpType getCorpType() {
public String getCorpType() {
return corpType;
}
public void setCorpType(CorpType corpType) {
this.corpType = corpType;
@JSONField(serialize = false)
public CorpType getFormatCorpType() {
return corpType != null ? CorpType.valueOf(corpType) : null;
}
public String getCorpName() {
return corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getSquareLogoUrl() {
return squareLogoUrl;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public String getRoundLogoUrl() {
return roundLogoUrl;
}
public Integer getUserMax() {
return userMax;
}
public Integer getAgentMax() {
return agentMax;
}
public String getWxQrCode() {
return wxQrCode;
}
// ---------- setter 应该全部去掉
public void setCorpId(String corpId) {
this.corpId = corpId;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl;
}
public void setRoundLogoUrl(String roundLogoUrl) {
this.roundLogoUrl = roundLogoUrl;
}
public int getUserMax() {
return userMax;
public void setCorpType(String corpType) {
this.corpType = corpType;
}
public void setUserMax(int userMax) {
public void setUserMax(Integer userMax) {
this.userMax = userMax;
}
public int getAgentMax() {
return agentMax;
}
public void setAgentMax(int agentMax) {
public void setAgentMax(Integer agentMax) {
this.agentMax = agentMax;
}
public String getWxqrcode() {
return wxqrcode;
}
public void setWxqrcode(String wxqrcode) {
this.wxqrcode = wxqrcode;
public void setWxQrCode(String wxQrCode) {
this.wxQrCode = wxQrCode;
}
@Override
public String toString() {
return "Corpinfo [corpid=" + corpid + ", corpName=" + corpName
return "CorpInfo [corpType=" + corpId + ", corpName=" + corpName
+ ", squareLogoUrl=" + squareLogoUrl + ", roundLogoUrl="
+ roundLogoUrl + ", corpType=" + corpType + ", userMax="
+ userMax + ", agentMax=" + agentMax + ", wxqrcode=" + wxqrcode
+ userMax + ", agentMax=" + agentMax + ", wxQrCode=" + wxQrCode
+ "]";
}
}
@@ -2,8 +2,12 @@ package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
/**
* name-value
*
* @className NameValue
* @author jy
* @date 2015年3月29日
@@ -16,11 +20,9 @@ public class NameValue implements Serializable {
private String name;
private String value;
public NameValue() {
}
public NameValue(String name, String value) {
@JSONCreator
public NameValue(@JSONField(name = "name") String name,
@JSONField(name = "value") String value) {
this.name = name;
this.value = value;
}
@@ -33,14 +35,6 @@ public class NameValue implements Serializable {
return value;
}
public void setName(String name) {
this.name = name;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "NameValue [name=" + name + ", value=" + value + "]";
@@ -37,7 +37,7 @@ public class OUserInfo implements Serializable {
* 授权方企业信息
*/
@JSONField(name = "corp_info")
private Corpinfo corpinfo;
private CorpInfo corpInfo;
/**
* 该管理员在该提供商中能使用的应用列表
*/
@@ -53,46 +53,48 @@ public class OUserInfo implements Serializable {
return isSysAdmin;
}
public void setSysAdmin(boolean isSysAdmin) {
this.isSysAdmin = isSysAdmin;
}
public boolean isInnerAdmin() {
return isInnerAdmin;
}
public void setInnerAdmin(boolean isInnerAdmin) {
this.isInnerAdmin = isInnerAdmin;
}
public User getAdminInfo() {
return adminInfo;
}
public void setAdminInfo(User adminInfo) {
this.adminInfo = adminInfo;
}
public Corpinfo getCorpinfo() {
return corpinfo;
}
public void setCorpinfo(Corpinfo corpinfo) {
this.corpinfo = corpinfo;
public CorpInfo getCorpInfo() {
return corpInfo;
}
public List<AgentItem> getAgentInfo() {
return agentInfo;
}
public void setAgentInfo(List<AgentItem> agentInfo) {
this.agentInfo = agentInfo;
}
public AuthInfo getAuthInfo() {
return authInfo;
}
// ---------- setter 应该全部去掉
public void setSysAdmin(boolean isSysAdmin) {
this.isSysAdmin = isSysAdmin;
}
public void setInnerAdmin(boolean isInnerAdmin) {
this.isInnerAdmin = isInnerAdmin;
}
public void setAdminInfo(User adminInfo) {
this.adminInfo = adminInfo;
}
public void setCorpInfo(CorpInfo corpInfo) {
this.corpInfo = corpInfo;
}
public void setAgentInfo(List<AgentItem> agentInfo) {
this.agentInfo = agentInfo;
}
public void setAuthInfo(AuthInfo authInfo) {
this.authInfo = authInfo;
}
@@ -100,8 +102,8 @@ public class OUserInfo implements Serializable {
@Override
public String toString() {
return "OUserInfo [isSysAdmin=" + isSysAdmin + ", isInnerAdmin="
+ isInnerAdmin + ", adminInfo=" + adminInfo + ", corpinfo="
+ corpinfo + ", agentInfo=" + agentInfo + ", authInfo="
+ isInnerAdmin + ", adminInfo=" + adminInfo + ", corpInfo="
+ corpInfo + ", agentInfo=" + agentInfo + ", authInfo="
+ authInfo + "]";
}
@@ -126,28 +128,30 @@ public class OUserInfo implements Serializable {
* 授权的通讯录部门
*/
@JSONField(name = "department")
private List<DepartmentItem> departmentItems;
private List<DepartItem> departItems;
public List<AgentItem> getAgentItems() {
return agentItems;
}
public List<DepartItem> getDepartItems() {
return departItems;
}
// ---------- setter 应该全部去掉
public void setAgentItems(List<AgentItem> agentItems) {
this.agentItems = agentItems;
}
public List<DepartmentItem> getDepartmentItems() {
return departmentItems;
}
public void setDepartmentItems(List<DepartmentItem> departmentItems) {
this.departmentItems = departmentItems;
public void setDepartItems(List<DepartItem> departItems) {
this.departItems = departItems;
}
@Override
public String toString() {
return "AuthInfo [agentItems=" + agentItems + ", departmentItems="
+ departmentItems + "]";
return "AuthInfo [agentItems=" + agentItems + ", departItems="
+ departItems + "]";
}
}
@@ -167,49 +171,57 @@ public class OUserInfo implements Serializable {
* 管理员对应用的权限
*/
@JSONField(name = "auth_type")
private AgentAuthType authType;
private int authType;
/**
* 服务商套件中的对应应用id
*/
private int appid;
@JSONField(name = "appid")
private int appId;
/**
* 授权方应用敏感权限组,目前仅有get_location,表示是否有权限设置应用获取地理位置的开关
*/
@JSONField(name = "api_group")
private List<String> apiGroup;
public AgentAuthType getAuthType() {
public int getAuthType() {
return authType;
}
public void setAuthType(int authType) {
@JSONField(serialize = false)
public AgentAuthType getFormatAuthType() {
if (authType == 0) {
this.authType = AgentAuthType.USE;
return AgentAuthType.USE;
} else if (authType == 1) {
this.authType = AgentAuthType.MANAGE;
return AgentAuthType.MANAGE;
}
this.authType = null;
return null;
}
public int getAppid() {
return appid;
}
public void setAppid(int appid) {
this.appid = appid;
public int getAppId() {
return appId;
}
public List<String> getApiGroup() {
return apiGroup;
}
// ---------- setter 应该全部去掉
public void setAuthType(int authType) {
this.authType = authType;
}
public void setAppId(int appId) {
this.appId = appId;
}
public void setApiGroup(List<String> apiGroup) {
this.apiGroup = apiGroup;
}
@Override
public String toString() {
return "AgentItem [authType=" + authType + ", appid=" + appid
return "AgentItem [authType=" + authType + ", appId=" + appId
+ ", apiGroup=" + apiGroup + ", " + super.toString() + "]";
}
}
@@ -217,13 +229,13 @@ public class OUserInfo implements Serializable {
/**
* 授权的通讯录部门
*
* @className DepartmentItem
* @className DepartItem
* @author jy
* @date 2015年6月22日
* @since JDK 1.7
* @see
*/
public static class DepartmentItem extends Party {
public static class DepartItem extends Party {
private static final long serialVersionUID = 556556672204642407L;
@@ -236,14 +248,15 @@ public class OUserInfo implements Serializable {
return writable;
}
// ---------- setter 应该全部去掉
public void setWritable(boolean writable) {
this.writable = writable;
}
@Override
public String toString() {
return "DepartmentItem [writable=" + writable + ", "
+ super.toString() + "]";
return "DepartItem [writable=" + writable + ", " + super.toString()
+ "]";
}
}
}
@@ -2,6 +2,8 @@ package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField;
/**
* 部门对象
*
@@ -26,62 +28,64 @@ public class Party implements Serializable {
/**
* 父亲部门id。根部门id为1
*/
private int parentid;
@JSONField(name = "parentid")
private int parentId;
/**
* 在父部门中的次序。从1开始,数字越大排序越靠后
*/
private int order;
private Integer order;
public Party() {
}
public Party(int id, String name) {
this(id, name, 0, 0);
public Party(String name) {
this.name = name;
}
public Party(int id, String name, int parentid, int order) {
public Party(int id, String name, int parentId) {
this.id = id;
this.name = name;
this.parentid = parentid;
this.order = order;
this.parentId = parentId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public int getParentId() {
return parentId;
}
public Integer getOrder() {
return order;
}
// ---------- setter 应该全部去掉
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public int getParentid() {
return parentid;
public void setParentId(int parentId) {
this.parentId = parentId;
}
public void setParentid(int parentid) {
this.parentid = parentid;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
public void setOrder(Integer order) {
this.order = order;
}
@Override
public String toString() {
return "Party [id=" + id + ", name=" + name + ", parentid=" + parentid
return "Party [id=" + id + ", name=" + name + ", parentId=" + parentId
+ ", order=" + order + "]";
}
}
@@ -45,14 +45,16 @@ public class Tag implements Serializable {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
// ---------- setter 应该全部去掉
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@@ -1,7 +1,6 @@
package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +24,8 @@ public class User implements Serializable {
/**
* 必须 员工UserID。对应管理端的帐号,企业内必须唯一。长度为1~64个字符
*/
private String userid;
@JSONField(name = "userid")
private String userId;
/**
* 必须 成员名称。长度为1~64个字符
*/
@@ -34,7 +34,7 @@ public class User implements Serializable {
* 非必须 成员所属部门id列表。注意,每个部门的直属员工上限为1000个
*/
@JSONField(name = "department")
private List<Integer> partys;
private List<Integer> partyIds;
/**
* 非必须 职位信息。长度为0~64个字符
*/
@@ -46,7 +46,7 @@ public class User implements Serializable {
/**
* 非必须 性别。gender=0表示男,=1表示女。默认gender=0
*/
private int gender;
private Integer gender;
/**
* 非必须 办公电话。长度为0~64个字符
*/
@@ -58,7 +58,8 @@ public class User implements Serializable {
/**
* 非必须 微信号。企业内必须唯一
*/
private String weixinid;
@JSONField(name = "weixinid")
private String weixinId;
/**
* 头像url。注:如果要获取小图将url最后的"/0"改成"/64"即可
*/
@@ -66,7 +67,7 @@ public class User implements Serializable {
/**
* 关注状态: 1=已关注,2=已冻结,4=未关注
*/
private int status;
private Integer status;
/**
* 启用/禁用成员。1表示启用成员,0表示禁用成员
*/
@@ -77,148 +78,84 @@ public class User implements Serializable {
private List<NameValue> extattr;
public User() {
this.extattr = new ArrayList<NameValue>();
}
public User(String userid, String name) {
this(userid, name, null, null, null);
}
/**
* mobile/weixinid/email三者不能同时为空
*
* @param userid
* 用户ID
* @param name
* 用户昵称
* @param tel
* 号码
* @param email
* 邮箱
* @param weixinid
* 微信ID
*/
public User(String userid, String name, String tel, String email,
String weixinid) {
this.userid = userid;
public User(String userId, String name) {
this.userId = userId;
this.name = name;
this.tel = tel;
this.email = email;
this.weixinid = weixinid;
this.extattr = new ArrayList<NameValue>();
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
public String getUserId() {
return userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
public List<Integer> getPartyIds() {
return partyIds;
}
public List<Integer> getPartys() {
return partys;
}
public void setPartys(List<Integer> partys) {
this.partys = partys;
}
public void setPartys(Integer... partys) {
this.partys = Arrays.asList(partys);
public void setPartyIds(Integer... partyIds) {
this.partyIds = Arrays.asList(partyIds);
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public int getGender() {
public Integer getGender() {
return gender;
}
@JSONField(serialize = false)
public Gender getFormatGender() {
if (gender == 0) {
return Gender.male;
} else if (gender == 1) {
return Gender.female;
} else {
return Gender.unknown;
if (gender != null) {
if (gender.intValue() == 0) {
return Gender.male;
} else if (gender.intValue() == 1) {
return Gender.female;
} else {
return Gender.unknown;
}
}
}
public void setGender(int gender) {
this.gender = gender;
return null;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
public String getWeixinId() {
return weixinId;
}
public String getWeixinid() {
return weixinid;
}
public void setWeixinid(String weixinid) {
this.weixinid = weixinid;
}
@JSONField(serialize = false)
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public UserStatus getFormatStatus() {
for (UserStatus userStatus : UserStatus.values()) {
if (userStatus.getVal() == status) {
return userStatus;
if (status != null) {
for (UserStatus userStatus : UserStatus.values()) {
if (userStatus.getVal() == status) {
return userStatus;
}
}
}
return null;
}
public void setStatus(int status) {
this.status = status;
}
public int getStatus() {
public Integer getStatus() {
return status;
}
@@ -226,7 +163,11 @@ public class User implements Serializable {
return enable;
}
@JSONField(serialize = false, deserialize = false)
public void setEnable(boolean enable) {
this.enable = enable ? 1 : 0;
}
@JSONField(serialize = false)
public boolean getFormatEnable() {
if (enable != null) {
return enable.intValue() == 1;
@@ -234,10 +175,6 @@ public class User implements Serializable {
return false;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
public List<NameValue> getExtattr() {
return extattr;
}
@@ -251,20 +188,65 @@ public class User implements Serializable {
}
public void pushExattr(String name, String value) {
pushExattr(new NameValue(name, value));
extattr.add(new NameValue(name, value));
}
public void pushExattr(NameValue nameValue) {
extattr.add(nameValue);
// ---------- setter 应该全部去掉
public void setUserId(String userId) {
this.userId = userId;
}
public void setName(String name) {
this.name = name;
}
public void setPartyIds(List<Integer> partyIds) {
this.partyIds = partyIds;
}
public void setPosition(String position) {
this.position = position;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public void setTel(String tel) {
this.tel = tel;
}
public void setEmail(String email) {
this.email = email;
}
public void setWeixinId(String weixinId) {
this.weixinId = weixinId;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setEnable(Integer enable) {
this.enable = enable;
}
@Override
public String toString() {
return "User [userid=" + userid + ", name=" + name + ", partys="
+ partys + ", position=" + position + ", mobile=" + mobile
+ ", gender=" + getFormatGender() + ", tel=" + tel + ", email="
+ email + ", weixinid=" + weixinid + ", avatar=" + avatar
+ ", status=" + getFormatStatus() + ", enable="
+ getFormatEnable() + ", extattr=" + extattr + "]";
return "User [userId=" + userId + ", name=" + name + ", partyIds="
+ partyIds + ", position=" + position + ", mobile=" + mobile
+ ", gender=" + gender + ", tel=" + tel + ", email=" + email
+ ", weixinId=" + weixinId + ", avatar=" + avatar + ", status="
+ status + ", enable=" + enable + ", extattr=" + extattr + "]";
}
}
@@ -45,7 +45,7 @@ public class BatchTest extends TokenTest {
@Test
public void replaceparty() throws WeixinException {
String mediaId = mediaApi.batchUploadParties(Arrays.asList(new Party(5,
"部门1", 1, 1), new Party(6, "部门2", 1, 1)));
"部门1", 1), new Party(6, "部门2", 1)));
String jobId = batchApi.replaceParty(mediaId, new Callback(
"http://182.254.188.133:8090", "gp2eGT5mIpngr",
"BRYfV4zPFUJb3v3MySNBg1ERKE3vyyMRoScu76vFySv"));
@@ -30,14 +30,14 @@ public class PartyTest extends TokenTest {
@Test
public void create() throws WeixinException {
Party Party = new Party(1, "苦逼组");
Party Party = new Party(1, "苦逼组", 1);
int id = partyApi.createParty(Party);
Assert.assertTrue(id > 0);
}
@Test
public void update() throws WeixinException {
Party Party = new Party(2, "苦逼组111");
Party Party = new Party(2, "苦逼组111", 1);
JsonResult result = partyApi.updateParty(Party);
Assert.assertEquals("updated", result.getDesc());
}
@@ -35,9 +35,8 @@ public class UserTest extends TokenTest {
@Test
public void create() throws WeixinException {
User user = new User("u001", "jack");
user.setMobile("13500000000");
user.setPartys(1);
User user = new User("id", "name");
user.setPartyIds(1);
user.pushExattr("爱好", "code");
JsonResult result = userApi.createUser(user);
Assert.assertEquals("created", result.getDesc());
@@ -45,18 +44,16 @@ public class UserTest extends TokenTest {
@Test
public void batchUpload() throws WeixinException {
User user = new User("u001", "jack");
user.setMobile("13500000000");
user.setPartys(1);
User user = new User("id", "name");
user.setPartyIds(1);
String mediaId = mediaApi.batchUploadUsers(Arrays.asList(user));
System.err.println(mediaId);
}
@Test
public void update() throws WeixinException {
User user = new User("u001", "ted");
user.setMobile("13500000000");
user.setPartys(1);
User user = new User("id", "name");
user.setPartyIds(1);
user.pushExattr("爱好", "code");
JsonResult result = userApi.updateUser(user);
Assert.assertEquals("updated", result.getDesc());