mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-02 12:38:22 +08:00
🐛 #1713 企业微信修复获取企业已配置的「联系我」方式详情接口
* 外部联系人客户详情新增增加字段 增加字段:remark_corp_name,addWay,oper_userid Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改测试类 Signed-off-by: huangxiaoming <huangxm129@163.com> * 客户标签组查询列表功能修改 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改测试类 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改 add_way字段错误 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改添加企业客户标签后无返回信息 Signed-off-by: huangxiaoming <huangxm129@163.com> * 外部联系人客户详情新增增加字段 增加字段:remark_corp_name,addWay,oper_userid Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改测试类 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改测试类 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改 add_way字段错误 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改添加企业客户标签后无返回信息 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改错误 Signed-off-by: huangxiaoming <huangxm129@163.com> * 修改冲突 Signed-off-by: huangxiaoming <huangxm129@163.com> * 获取企业已配置的「联系我」方式:添加二维码字段 Signed-off-by: huangxiaoming <huangxm129@163.com> * 获取企业已配置的「联系我」方式对象无返回信息BUG Signed-off-by: huangxiaoming <huangxm129@163.com>
This commit is contained in:
@ -28,12 +28,12 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
@Override
|
||||
public WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {
|
||||
|
||||
if (info.getUsers() != null && info.getUsers().size() > 100) {
|
||||
if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
|
||||
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
|
||||
}
|
||||
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY);
|
||||
String responseContent = this.mainService.post(url, info.toJson());
|
||||
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
|
||||
|
||||
return WxCpContactWayResult.fromJson(responseContent);
|
||||
}
|
||||
@ -45,21 +45,20 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_WAY);
|
||||
String responseContent = this.mainService.post(url, json.toString());
|
||||
|
||||
return WxCpContactWayInfo.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {
|
||||
if (StringUtils.isBlank(info.getConfigId())) {
|
||||
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
|
||||
throw new RuntimeException("更新「联系我」方式需要指定configId");
|
||||
}
|
||||
if (info.getUsers() != null && info.getUsers().size() > 100) {
|
||||
if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
|
||||
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
|
||||
}
|
||||
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY);
|
||||
String responseContent = this.mainService.post(url, info.toJson());
|
||||
String responseContent = this.mainService.post(url, info.getContactWay().toJson());
|
||||
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@ package me.chanjar.weixin.cp.bean;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpConclusionAdapter;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
@ -18,6 +20,12 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class WxCpContactWayInfo {
|
||||
|
||||
@SerializedName("contact_way")
|
||||
private ContactWay contactWay;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ContactWay {
|
||||
/**
|
||||
* 联系方式的配置id
|
||||
*/
|
||||
@ -75,6 +83,14 @@ public class WxCpContactWayInfo {
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 联系二维码的URL,仅在scene为2时返回
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("qr_code")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
|
||||
@ -137,8 +153,8 @@ public class WxCpContactWayInfo {
|
||||
*/
|
||||
private Conclusion conclusions;
|
||||
|
||||
public static WxCpContactWayInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class);
|
||||
public static WxCpContactWayInfo.ContactWay fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.ContactWay.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
@ -164,6 +180,17 @@ public class WxCpContactWayInfo {
|
||||
private String miniProgramPage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static WxCpContactWayInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public enum TYPE {
|
||||
/**
|
||||
* 单人
|
||||
|
||||
@ -11,12 +11,12 @@ import java.lang.reflect.Type;
|
||||
*
|
||||
* @author element
|
||||
*/
|
||||
public class WxCpConclusionAdapter implements JsonSerializer<WxCpContactWayInfo.Conclusion>, JsonDeserializer<WxCpContactWayInfo.Conclusion> {
|
||||
public class WxCpConclusionAdapter implements JsonSerializer<WxCpContactWayInfo.ContactWay.Conclusion>, JsonDeserializer<WxCpContactWayInfo.ContactWay.Conclusion> {
|
||||
@Override
|
||||
public WxCpContactWayInfo.Conclusion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
public WxCpContactWayInfo.ContactWay.Conclusion deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
|
||||
WxCpContactWayInfo.Conclusion conclusion = new WxCpContactWayInfo.Conclusion();
|
||||
WxCpContactWayInfo.ContactWay.Conclusion conclusion = new WxCpContactWayInfo.ContactWay.Conclusion();
|
||||
|
||||
if (jsonObject.get("text") != null) {
|
||||
JsonObject jsonText = jsonObject.get("text").getAsJsonObject();
|
||||
@ -77,7 +77,7 @@ public class WxCpConclusionAdapter implements JsonSerializer<WxCpContactWayInfo.
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(WxCpContactWayInfo.Conclusion src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
public JsonElement serialize(WxCpContactWayInfo.ContactWay.Conclusion src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject json = new JsonObject();
|
||||
if (StringUtils.isNotBlank(src.getTextContent())) {
|
||||
JsonObject jsonText = new JsonObject();
|
||||
|
||||
@ -35,21 +35,24 @@ public class WxCpExternalContactServiceImplTest {
|
||||
@Test
|
||||
public void testAddContactWay() throws WxErrorException {
|
||||
|
||||
final String concatUserId = "符合要求的userId";
|
||||
final String concatUserId = "HuangXiaoMing";
|
||||
|
||||
WxCpContactWayInfo.ContactWay wayInfo = new WxCpContactWayInfo.ContactWay();
|
||||
wayInfo.setType(WxCpContactWayInfo.TYPE.SIGLE);
|
||||
wayInfo.setScene(WxCpContactWayInfo.SCENE.QRCODE);
|
||||
wayInfo.setUsers(Lists.newArrayList(concatUserId));
|
||||
wayInfo.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date()));
|
||||
|
||||
WxCpContactWayInfo info = new WxCpContactWayInfo();
|
||||
info.setType(WxCpContactWayInfo.TYPE.SIGLE);
|
||||
info.setScene(WxCpContactWayInfo.SCENE.MINIPROGRAM);
|
||||
info.setUsers(Lists.newArrayList(concatUserId));
|
||||
info.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date()));
|
||||
info.setContactWay(wayInfo);
|
||||
this.wxCpService.getExternalContactService().addContactWay(info);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetContactWay() throws WxErrorException {
|
||||
final String configId = "2d7a68c657663afbd1d90db19a4b5ee9";
|
||||
final String configId = "39fea3d93e30faaa8c7a9edd4cfe4d08";
|
||||
WxCpContactWayInfo contactWayInfo = this.wxCpService.getExternalContactService().getContactWay(configId);
|
||||
System.out.println(contactWayInfo);
|
||||
System.out.println(contactWayInfo.toJson());
|
||||
assertNotNull(contactWayInfo);
|
||||
}
|
||||
|
||||
@ -57,10 +60,12 @@ public class WxCpExternalContactServiceImplTest {
|
||||
public void testUpdateContactWay() throws WxErrorException {
|
||||
final String configId = "2d7a68c657663afbd1d90db19a4b5ee9";
|
||||
final String concatUserId = "符合要求的userId";
|
||||
WxCpContactWayInfo.ContactWay wayInfo = new WxCpContactWayInfo.ContactWay();
|
||||
wayInfo.setConfigId(configId);
|
||||
wayInfo.setUsers(Lists.newArrayList(concatUserId));
|
||||
wayInfo.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date()));
|
||||
WxCpContactWayInfo info = new WxCpContactWayInfo();
|
||||
info.setConfigId(configId);
|
||||
info.setUsers(Lists.newArrayList(concatUserId));
|
||||
info.setRemark("CreateDate:" + DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(new Date()));
|
||||
info.setContactWay(wayInfo);
|
||||
WxCpBaseResp resp = this.wxCpService.getExternalContactService().updateContactWay(info);
|
||||
System.out.println(resp);
|
||||
assertNotNull(resp);
|
||||
|
||||
Reference in New Issue
Block a user