Skip to content

Commit

Permalink
🐛 #1713 企业微信修复获取企业已配置的「联系我」方式详情接口
Browse files Browse the repository at this point in the history
* 外部联系人客户详情新增增加字段

增加字段: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]>
  • Loading branch information
huangxm129 authored Aug 16, 2020
1 parent ce8f4f8 commit a7ea5f5
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -45,21 +45,20 @@ public WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxError

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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;

Expand All @@ -18,124 +20,168 @@
@NoArgsConstructor
public class WxCpContactWayInfo {

/**
* 联系方式的配置id
*/
@SerializedName("config_id")
private String configId;

/**
* <pre>
* 必填
* 联系方式类型,1-单人, 2-多人
* </pre>
*/
private TYPE type;

/**
* <pre>
* 必填
* 场景,1-在小程序中联系,2-通过二维码联系
* </pre>
*/
private SCENE scene;

/**
* <pre>
* 非必填
* 在小程序中联系时使用的控件样式
* <b>单人样式(type=1)时可选1,2,3</b>
* <b>多人样式(type=2)时可选1,2</b>
* </pre>
*/
private Integer style;

/**
* <pre>
* 非必填
* 联系方式的备注信息,用于助记,不超过30个字符
* </pre>
*/
private String remark;

/**
* <pre>
* 非必填
* 外部客户添加时是否无需验证,默认为true
* </pre>
*/
@SerializedName("skip_verify")
private Boolean skipVerify = Boolean.TRUE;

/**
* <pre>
* 非必填
* 企业自定义的state参数,用于区分不同的添加渠道,在调用“获取外部联系人详情(WxCpExternalContactService.getContactDetail)” 时会返回该参数值,不超过30个字符
* </pre>
*/
private String state;

/**
* <pre>
* 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
* </pre>
*/
@SerializedName("user")
private List<String> users;


/**
* <pre>
* 非必填
* 使用该联系方式的部门id列表,只在type为2时有效
* </pre>
*/
@SerializedName("party")
private List<String> partys;

/**
* <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时有效,默认为添加好友后24小时
* </pre>
*/
@SerializedName("chat_expires_in")
private Integer chatExpiresIn;

/**
* <pre>
* 非必填
* 可进行临时会话的客户unionid,该参数仅在is_temp为true时有效,如不指定则不进行限制
* </pre>
*/
@SerializedName("unionid")
private String unionId;

/**
* <pre>
* 非必填
* 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效
* </pre>
*/
private Conclusion conclusions;
@SerializedName("contact_way")
private ContactWay contactWay;

@Getter
@Setter
public static class ContactWay {
/**
* 联系方式的配置id
*/
@SerializedName("config_id")
private String configId;

/**
* <pre>
* 必填
* 联系方式类型,1-单人, 2-多人
* </pre>
*/
private TYPE type;

/**
* <pre>
* 必填
* 场景,1-在小程序中联系,2-通过二维码联系
* </pre>
*/
private SCENE scene;

/**
* <pre>
* 非必填
* 在小程序中联系时使用的控件样式
* <b>单人样式(type=1)时可选1,2,3</b>
* <b>多人样式(type=2)时可选1,2</b>
* </pre>
*/
private Integer style;

/**
* <pre>
* 非必填
* 联系方式的备注信息,用于助记,不超过30个字符
* </pre>
*/
private String remark;

/**
* <pre>
* 非必填
* 外部客户添加时是否无需验证,默认为true
* </pre>
*/
@SerializedName("skip_verify")
private Boolean skipVerify = Boolean.TRUE;

/**
* <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>
* 非必填
* 是否临时会话模式,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时有效,默认为添加好友后24小时
* </pre>
*/
@SerializedName("chat_expires_in")
private Integer chatExpiresIn;

/**
* <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;
}

}


public static WxCpContactWayInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpContactWayInfo.class);
Expand All @@ -145,25 +191,6 @@ 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;
}

public enum TYPE {
/**
* 单人
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
*
* @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();
Expand Down Expand Up @@ -77,7 +77,7 @@ public WxCpContactWayInfo.Conclusion deserialize(JsonElement json, Type typeOfT,
}

@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();
Expand Down
Loading

0 comments on commit a7ea5f5

Please sign in to comment.