Skip to content

Commit

Permalink
🎨 #1265 企业微信通讯录接口支持设置地址
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Nov 16, 2019
1 parent ac67482 commit 92c5d62
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class WxCpUser implements Serializable {
private Gender gender;
private String email;
private String avatar;
/**
* 地址。长度最大128个字符
*/
private String address;
private String avatarMediaId;
private Integer status;
private Integer enable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public WxCpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
user.setGender(Gender.fromCode(GsonHelper.getString(o, "gender")));
user.setEmail(GsonHelper.getString(o, "email"));
user.setAvatar(GsonHelper.getString(o, "avatar"));
user.setAddress(GsonHelper.getString(o, "address"));
user.setAvatarMediaId(GsonHelper.getString(o, "avatar_mediaid"));
user.setStatus(GsonHelper.getInteger(o, "status"));
user.setEnable(GsonHelper.getInteger(o, "enable"));
Expand Down Expand Up @@ -186,6 +187,9 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
if (user.getAvatar() != null) {
o.addProperty("avatar", user.getAvatar());
}
if (user.getAddress() != null) {
o.addProperty("address", user.getAddress());
}
if (user.getAvatarMediaId() != null) {
o.addProperty("avatar_mediaid", user.getAvatarMediaId());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package me.chanjar.weixin.cp.util.json;

import org.testng.annotations.*;

import me.chanjar.weixin.cp.bean.WxCpUser;
import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -32,6 +31,7 @@ public void testDeserialize() {
" \"isleader\": 1,\n" +
" \"avatar\": \"http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0\",\n" +
" \"telephone\": \"020-123456\",\n" +
" \"address\": \"广州市海珠区新港中路\"," +
" \"enable\": 1,\n" +
" \"alias\": \"jackzhang\",\n" +
" \"extattr\": {\n" +
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testDeserialize() {
assertThat(user.getOrders()[0]).isEqualTo(1);
assertThat(user.getOrders()[1]).isEqualTo(2);


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

final WxCpUser.ExternalAttribute externalAttr1 = user.getExternalAttrs().get(0);
Expand Down

0 comments on commit 92c5d62

Please sign in to comment.