Skip to content

Commit a7ea5f5

Browse files
authored
🐛 #1713 企业微信修复获取企业已配置的「联系我」方式详情接口
* 外部联系人客户详情新增增加字段 增加字段:remark_corp_name,addWay,oper_userid Signed-off-by: huangxiaoming <[email protected]> * 修改测试类 Signed-off-by: huangxiaoming <[email protected]> * 客户标签组查询列表功能修改 Signed-off-by: huangxiaoming <[email protected]> * 修改测试类 Signed-off-by: huangxiaoming <[email protected]> * 修改 add_way字段错误 Signed-off-by: huangxiaoming <[email protected]> * 修改添加企业客户标签后无返回信息 Signed-off-by: huangxiaoming <[email protected]> * 外部联系人客户详情新增增加字段 增加字段:remark_corp_name,addWay,oper_userid Signed-off-by: huangxiaoming <[email protected]> * 修改测试类 Signed-off-by: huangxiaoming <[email protected]> * 修改测试类 Signed-off-by: huangxiaoming <[email protected]> * 修改 add_way字段错误 Signed-off-by: huangxiaoming <[email protected]> * 修改添加企业客户标签后无返回信息 Signed-off-by: huangxiaoming <[email protected]> * 修改错误 Signed-off-by: huangxiaoming <[email protected]> * 修改冲突 Signed-off-by: huangxiaoming <[email protected]> * 获取企业已配置的「联系我」方式:添加二维码字段 Signed-off-by: huangxiaoming <[email protected]> * 获取企业已配置的「联系我」方式对象无返回信息BUG Signed-off-by: huangxiaoming <[email protected]>
1 parent ce8f4f8 commit a7ea5f5

File tree

4 files changed

+188
-157
lines changed

4 files changed

+188
-157
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
2828
@Override
2929
public WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {
3030

31-
if (info.getUsers() != null && info.getUsers().size() > 100) {
31+
if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
3232
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
3333
}
3434

3535
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY);
36-
String responseContent = this.mainService.post(url, info.toJson());
36+
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
3737

3838
return WxCpContactWayResult.fromJson(responseContent);
3939
}
@@ -45,21 +45,20 @@ public WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxError
4545

4646
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_WAY);
4747
String responseContent = this.mainService.post(url, json.toString());
48-
4948
return WxCpContactWayInfo.fromJson(responseContent);
5049
}
5150

5251
@Override
5352
public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {
54-
if (StringUtils.isBlank(info.getConfigId())) {
53+
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
5554
throw new RuntimeException("更新「联系我」方式需要指定configId");
5655
}
57-
if (info.getUsers() != null && info.getUsers().size() > 100) {
56+
if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
5857
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
5958
}
6059

6160
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY);
62-
String responseContent = this.mainService.post(url, info.toJson());
61+
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
6362

6463
return WxCpBaseResp.fromJson(responseContent);
6564
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpContactWayInfo.java

Lines changed: 164 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import com.google.gson.annotations.JsonAdapter;
44
import com.google.gson.annotations.SerializedName;
55
import lombok.Data;
6+
import lombok.Getter;
67
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
79
import me.chanjar.weixin.cp.util.json.WxCpConclusionAdapter;
810
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
911

@@ -18,124 +20,168 @@
1820
@NoArgsConstructor
1921
public class WxCpContactWayInfo {
2022

21-
/**
22-
* 联系方式的配置id
23-
*/
24-
@SerializedName("config_id")
25-
private String configId;
26-
27-
/**
28-
* <pre>
29-
* 必填
30-
* 联系方式类型,1-单人, 2-多人
31-
* </pre>
32-
*/
33-
private TYPE type;
34-
35-
/**
36-
* <pre>
37-
* 必填
38-
* 场景,1-在小程序中联系,2-通过二维码联系
39-
* </pre>
40-
*/
41-
private SCENE scene;
42-
43-
/**
44-
* <pre>
45-
* 非必填
46-
* 在小程序中联系时使用的控件样式
47-
* <b>单人样式(type=1)时可选1,2,3</b>
48-
* <b>多人样式(type=2)时可选1,2</b>
49-
* </pre>
50-
*/
51-
private Integer style;
52-
53-
/**
54-
* <pre>
55-
* 非必填
56-
* 联系方式的备注信息,用于助记,不超过30个字符
57-
* </pre>
58-
*/
59-
private String remark;
60-
61-
/**
62-
* <pre>
63-
* 非必填
64-
* 外部客户添加时是否无需验证,默认为true
65-
* </pre>
66-
*/
67-
@SerializedName("skip_verify")
68-
private Boolean skipVerify = Boolean.TRUE;
69-
70-
/**
71-
* <pre>
72-
* 非必填
73-
* 企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情(WxCpExternalContactService.getContactDetail)” 时会返回该参数值,不超过30个字符
74-
* </pre>
75-
*/
76-
private String state;
77-
78-
/**
79-
* <pre>
80-
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
81-
* </pre>
82-
*/
83-
@SerializedName("user")
84-
private List<String> users;
85-
86-
87-
/**
88-
* <pre>
89-
* 非必填
90-
* 使用该联系方式的部门id列表,只在type为2时有效
91-
* </pre>
92-
*/
93-
@SerializedName("party")
94-
private List<String> partys;
95-
96-
/**
97-
* <pre>
98-
* 非必填
99-
* 是否临时会话模式,true表示使用临时会话模式,默认为false
100-
* </pre>
101-
*/
102-
@SerializedName("is_temp")
103-
private Boolean isTemp = Boolean.FALSE;
104-
105-
/**
106-
* <pre>
107-
* 非必填
108-
* 临时会话二维码有效期,以秒为单位。该参数仅在is_temp为true时有效,默认7天
109-
* </pre>
110-
*/
111-
@SerializedName("expires_in")
112-
private Integer expiresIn;
113-
114-
/**
115-
* <pre>
116-
* 非必填
117-
* 临时会话有效期,以秒为单位。该参数仅在is_temp为true时有效,默认为添加好友后24小时
118-
* </pre>
119-
*/
120-
@SerializedName("chat_expires_in")
121-
private Integer chatExpiresIn;
122-
123-
/**
124-
* <pre>
125-
* 非必填
126-
* 可进行临时会话的客户unionid,该参数仅在is_temp为true时有效,如不指定则不进行限制
127-
* </pre>
128-
*/
129-
@SerializedName("unionid")
130-
private String unionId;
131-
132-
/**
133-
* <pre>
134-
* 非必填
135-
* 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效
136-
* </pre>
137-
*/
138-
private Conclusion conclusions;
23+
@SerializedName("contact_way")
24+
private ContactWay contactWay;
25+
26+
@Getter
27+
@Setter
28+
public static class ContactWay {
29+
/**
30+
* 联系方式的配置id
31+
*/
32+
@SerializedName("config_id")
33+
private String configId;
34+
35+
/**
36+
* <pre>
37+
* 必填
38+
* 联系方式类型,1-单人, 2-多人
39+
* </pre>
40+
*/
41+
private TYPE type;
42+
43+
/**
44+
* <pre>
45+
* 必填
46+
* 场景,1-在小程序中联系,2-通过二维码联系
47+
* </pre>
48+
*/
49+
private SCENE scene;
50+
51+
/**
52+
* <pre>
53+
* 非必填
54+
* 在小程序中联系时使用的控件样式
55+
* <b>单人样式(type=1)时可选1,2,3</b>
56+
* <b>多人样式(type=2)时可选1,2</b>
57+
* </pre>
58+
*/
59+
private Integer style;
60+
61+
/**
62+
* <pre>
63+
* 非必填
64+
* 联系方式的备注信息,用于助记,不超过30个字符
65+
* </pre>
66+
*/
67+
private String remark;
68+
69+
/**
70+
* <pre>
71+
* 非必填
72+
* 外部客户添加时是否无需验证,默认为true
73+
* </pre>
74+
*/
75+
@SerializedName("skip_verify")
76+
private Boolean skipVerify = Boolean.TRUE;
77+
78+
/**
79+
* <pre>
80+
* 非必填
81+
* 企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情(WxCpExternalContactService.getContactDetail)” 时会返回该参数值,不超过30个字符
82+
* </pre>
83+
*/
84+
private String state;
85+
86+
/**
87+
* <pre>
88+
* 联系二维码的URL,仅在scene为2时返回
89+
* </pre>
90+
*/
91+
@SerializedName("qr_code")
92+
private String qrCode;
93+
94+
/**
95+
* <pre>
96+
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
97+
* </pre>
98+
*/
99+
@SerializedName("user")
100+
private List<String> users;
101+
102+
103+
/**
104+
* <pre>
105+
* 非必填
106+
* 使用该联系方式的部门id列表,只在type为2时有效
107+
* </pre>
108+
*/
109+
@SerializedName("party")
110+
private List<String> partys;
111+
112+
/**
113+
* <pre>
114+
* 非必填
115+
* 是否临时会话模式,true表示使用临时会话模式,默认为false
116+
* </pre>
117+
*/
118+
@SerializedName("is_temp")
119+
private Boolean isTemp = Boolean.FALSE;
120+
121+
/**
122+
* <pre>
123+
* 非必填
124+
* 临时会话二维码有效期,以秒为单位。该参数仅在is_temp为true时有效,默认7天
125+
* </pre>
126+
*/
127+
@SerializedName("expires_in")
128+
private Integer expiresIn;
129+
130+
/**
131+
* <pre>
132+
* 非必填
133+
* 临时会话有效期,以秒为单位。该参数仅在is_temp为true时有效,默认为添加好友后24小时
134+
* </pre>
135+
*/
136+
@SerializedName("chat_expires_in")
137+
private Integer chatExpiresIn;
138+
139+
/**
140+
* <pre>
141+
* 非必填
142+
* 可进行临时会话的客户unionid,该参数仅在is_temp为true时有效,如不指定则不进行限制
143+
* </pre>
144+
*/
145+
@SerializedName("unionid")
146+
private String unionId;
147+
148+
/**
149+
* <pre>
150+
* 非必填
151+
* 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效
152+
* </pre>
153+
*/
154+
private Conclusion conclusions;
155+
156+
public static WxCpContactWayInfo.ContactWay fromJson(String json) {
157+
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.ContactWay.class);
158+
}
159+
160+
public String toJson() {
161+
return WxCpGsonBuilder.create().toJson(this);
162+
}
163+
164+
/**
165+
* 结束语定义
166+
*/
167+
@Data
168+
@JsonAdapter(WxCpConclusionAdapter.class)
169+
public static class Conclusion {
170+
private String textContent;
171+
private String imgMediaId;
172+
private String imgPicUrl;
173+
private String linkTitle;
174+
private String linkPicUrl;
175+
private String linkDesc;
176+
private String linkUrl;
177+
private String miniProgramTitle;
178+
private String miniProgramPicMediaId;
179+
private String miniProgramAppId;
180+
private String miniProgramPage;
181+
}
182+
183+
}
184+
139185

140186
public static WxCpContactWayInfo fromJson(String json) {
141187
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class);
@@ -145,25 +191,6 @@ public String toJson() {
145191
return WxCpGsonBuilder.create().toJson(this);
146192
}
147193

148-
/**
149-
* 结束语定义
150-
*/
151-
@Data
152-
@JsonAdapter(WxCpConclusionAdapter.class)
153-
public static class Conclusion {
154-
private String textContent;
155-
private String imgMediaId;
156-
private String imgPicUrl;
157-
private String linkTitle;
158-
private String linkPicUrl;
159-
private String linkDesc;
160-
private String linkUrl;
161-
private String miniProgramTitle;
162-
private String miniProgramPicMediaId;
163-
private String miniProgramAppId;
164-
private String miniProgramPage;
165-
}
166-
167194
public enum TYPE {
168195
/**
169196
* 单人

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpConclusionAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
*
1212
* @author element
1313
*/
14-
public class WxCpConclusionAdapter implements JsonSerializer<WxCpContactWayInfo.Conclusion>, JsonDeserializer<WxCpContactWayInfo.Conclusion> {
14+
public class WxCpConclusionAdapter implements JsonSerializer<WxCpContactWayInfo.ContactWay.Conclusion>, JsonDeserializer<WxCpContactWayInfo.ContactWay.Conclusion> {
1515
@Override
16-
public WxCpContactWayInfo.Conclusion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
16+
public WxCpContactWayInfo.ContactWay.Conclusion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
1717
JsonObject jsonObject = json.getAsJsonObject();
1818

19-
WxCpContactWayInfo.Conclusion conclusion = new WxCpContactWayInfo.Conclusion();
19+
WxCpContactWayInfo.ContactWay.Conclusion conclusion = new WxCpContactWayInfo.ContactWay.Conclusion();
2020

2121
if (jsonObject.get("text") != null) {
2222
JsonObject jsonText = jsonObject.get("text").getAsJsonObject();
@@ -77,7 +77,7 @@ public WxCpContactWayInfo.Conclusion deserialize(JsonElement json, Type typeOfT,
7777
}
7878

7979
@Override
80-
public JsonElement serialize(WxCpContactWayInfo.Conclusion src, Type typeOfSrc, JsonSerializationContext context) {
80+
public JsonElement serialize(WxCpContactWayInfo.ContactWay.Conclusion src, Type typeOfSrc, JsonSerializationContext context) {
8181
JsonObject json = new JsonObject();
8282
if (StringUtils.isNotBlank(src.getTextContent())) {
8383
JsonObject jsonText = new JsonObject();

0 commit comments

Comments
 (0)