Skip to content

Commit

Permalink
🆕 #1397 企业微信通讯录成员类WxCpUser增加alias字段
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Feb 13, 2020
1 parent 47061bd commit 9406475
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package me.chanjar.weixin.cp.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* 微信用户信息.
*
Expand All @@ -28,13 +28,18 @@ public class WxCpUser implements Serializable {
private String email;
private String avatar;
private String thumbAvatar;

/**
* 地址。长度最大128个字符
*/
private String address;
private String avatarMediaId;
private Integer status;
private Integer enable;
/**
* 别名;第三方仅通讯录应用可获取
*/
private String alias;
private Integer isLeader;
/**
* is_leader_in_dept.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public WxCpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
user.setAvatarMediaId(GsonHelper.getString(o, "avatar_mediaid"));
user.setStatus(GsonHelper.getInteger(o, "status"));
user.setEnable(GsonHelper.getInteger(o, "enable"));
user.setAlias(GsonHelper.getString(o, "alias"));
user.setIsLeader(GsonHelper.getInteger(o, "isleader"));
user.setIsLeaderInDept(GsonHelper.getIntArray(o, "is_leader_in_dept"));
user.setHideMobile(GsonHelper.getInteger(o, "hide_mobile"));
Expand Down Expand Up @@ -203,6 +204,9 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
if (user.getEnable() != null) {
o.addProperty("enable", user.getEnable());
}
if (user.getAlias() != null) {
o.addProperty("alias", user.getAlias());
}
if (user.getIsLeader() != null) {
o.addProperty("isleader", user.getIsLeader());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void testDeserialize() {
assertThat(user.getOrders()[1]).isEqualTo(2);

assertThat(user.getAddress()).isEqualTo("广州市海珠区新港中路");
assertThat(user.getAlias()).isEqualTo("jackzhang");
assertThat(user.getExternalAttrs()).isNotEmpty();

final WxCpUser.ExternalAttribute externalAttr1 = user.getExternalAttrs().get(0);
Expand All @@ -102,6 +103,7 @@ public void testDeserialize() {
assertThat(externalAttr3.getAppid()).isEqualTo("wx8bd80126147df384");
assertThat(externalAttr3.getPagePath()).isEqualTo("/index");
assertThat(externalAttr3.getTitle()).isEqualTo("my miniprogram");

}

@Test
Expand Down

0 comments on commit 9406475

Please sign in to comment.