mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +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:
parent
ce8f4f8cab
commit
a7ea5f5bf3
@ -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,124 +20,168 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class WxCpContactWayInfo {
|
||||
|
||||
/**
|
||||
* 联系方式的配置id
|
||||
*/
|
||||
@SerializedName("config_id")
|
||||
private String configId;
|
||||
@SerializedName("contact_way")
|
||||
private ContactWay contactWay;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 必填
|
||||
* 联系方式类型,1-单人, 2-多人
|
||||
* </pre>
|
||||
*/
|
||||
private TYPE type;
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ContactWay {
|
||||
/**
|
||||
* 联系方式的配置id
|
||||
*/
|
||||
@SerializedName("config_id")
|
||||
private String configId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 必填
|
||||
* 场景,1-在小程序中联系,2-通过二维码联系
|
||||
* </pre>
|
||||
*/
|
||||
private SCENE scene;
|
||||
/**
|
||||
* <pre>
|
||||
* 必填
|
||||
* 联系方式类型,1-单人, 2-多人
|
||||
* </pre>
|
||||
*/
|
||||
private TYPE type;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 在小程序中联系时使用的控件样式
|
||||
* <b>单人样式(type=1)时可选1,2,3</b>
|
||||
* <b>多人样式(type=2)时可选1,2</b>
|
||||
* </pre>
|
||||
*/
|
||||
private Integer style;
|
||||
/**
|
||||
* <pre>
|
||||
* 必填
|
||||
* 场景,1-在小程序中联系,2-通过二维码联系
|
||||
* </pre>
|
||||
*/
|
||||
private SCENE scene;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 联系方式的备注信息,用于助记,不超过30个字符
|
||||
* </pre>
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 在小程序中联系时使用的控件样式
|
||||
* <b>单人样式(type=1)时可选1,2,3</b>
|
||||
* <b>多人样式(type=2)时可选1,2</b>
|
||||
* </pre>
|
||||
*/
|
||||
private Integer style;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 外部客户添加时是否无需验证,默认为true
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("skip_verify")
|
||||
private Boolean skipVerify = Boolean.TRUE;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 联系方式的备注信息,用于助记,不超过30个字符
|
||||
* </pre>
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情(WxCpExternalContactService.getContactDetail)” 时会返回该参数值,不超过30个字符
|
||||
* </pre>
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 外部客户添加时是否无需验证,默认为true
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("skip_verify")
|
||||
private Boolean skipVerify = Boolean.TRUE;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("user")
|
||||
private List<String> users;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情(WxCpExternalContactService.getContactDetail)” 时会返回该参数值,不超过30个字符
|
||||
* </pre>
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 联系二维码的URL,仅在scene为2时返回
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("qr_code")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("user")
|
||||
private List<String> users;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 使用该联系方式的部门id列表,只在type为2时有效
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("party")
|
||||
private List<String> partys;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 使用该联系方式的部门id列表,只在type为2时有效
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("party")
|
||||
private List<String> partys;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 是否临时会话模式,true表示使用临时会话模式,默认为false
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("is_temp")
|
||||
private Boolean isTemp = Boolean.FALSE;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 是否临时会话模式,true表示使用临时会话模式,默认为false
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("is_temp")
|
||||
private Boolean isTemp = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 临时会话二维码有效期,以秒为单位。该参数仅在is_temp为true时有效,默认7天
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("expires_in")
|
||||
private Integer expiresIn;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 临时会话二维码有效期,以秒为单位。该参数仅在is_temp为true时有效,默认7天
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("expires_in")
|
||||
private Integer expiresIn;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 临时会话有效期,以秒为单位。该参数仅在is_temp为true时有效,默认为添加好友后24小时
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("chat_expires_in")
|
||||
private Integer chatExpiresIn;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 临时会话有效期,以秒为单位。该参数仅在is_temp为true时有效,默认为添加好友后24小时
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("chat_expires_in")
|
||||
private Integer chatExpiresIn;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 可进行临时会话的客户unionid,该参数仅在is_temp为true时有效,如不指定则不进行限制
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 可进行临时会话的客户unionid,该参数仅在is_temp为true时有效,如不指定则不进行限制
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效
|
||||
* </pre>
|
||||
*/
|
||||
private Conclusion conclusions;
|
||||
|
||||
public static WxCpContactWayInfo.ContactWay fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.ContactWay.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束语定义
|
||||
*/
|
||||
@Data
|
||||
@JsonAdapter(WxCpConclusionAdapter.class)
|
||||
public static class Conclusion {
|
||||
private String textContent;
|
||||
private String imgMediaId;
|
||||
private String imgPicUrl;
|
||||
private String linkTitle;
|
||||
private String linkPicUrl;
|
||||
private String linkDesc;
|
||||
private String linkUrl;
|
||||
private String miniProgramTitle;
|
||||
private String miniProgramPicMediaId;
|
||||
private String miniProgramAppId;
|
||||
private String miniProgramPage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 非必填
|
||||
* 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效
|
||||
* </pre>
|
||||
*/
|
||||
private Conclusion conclusions;
|
||||
|
||||
public static WxCpContactWayInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class);
|
||||
@ -145,25 +191,6 @@ public class WxCpContactWayInfo {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束语定义
|
||||
*/
|
||||
@Data
|
||||
@JsonAdapter(WxCpConclusionAdapter.class)
|
||||
public static class Conclusion {
|
||||
private String textContent;
|
||||
private String imgMediaId;
|
||||
private String imgPicUrl;
|
||||
private String linkTitle;
|
||||
private String linkPicUrl;
|
||||
private String linkDesc;
|
||||
private String linkUrl;
|
||||
private String miniProgramTitle;
|
||||
private String miniProgramPicMediaId;
|
||||
private String miniProgramAppId;
|
||||
private String miniProgramPage;
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user