🆕 #3243【企业微信】增加获取敏感词规则列表和获取敏感词规则详情的接口

This commit is contained in:
令狐冲 2024-03-09 01:27:45 +08:00 committed by GitHub
parent 573f0f5e6f
commit 4abffdea81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 169 additions and 0 deletions

View File

@ -8,6 +8,8 @@ import me.chanjar.weixin.cp.bean.external.acquisition.*;
import me.chanjar.weixin.cp.bean.external.contact.*; import me.chanjar.weixin.cp.bean.external.contact.*;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleInfo;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleList;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -1134,6 +1136,31 @@ public interface WxCpExternalContactService {
*/ */
void delInterceptRule(String ruleId) throws WxErrorException; void delInterceptRule(String ruleId) throws WxErrorException;
/**
* 获取敏感词规则列表
*
* 企业和第三方应用可以通过此接口获取所有设置的敏感词规则列表
* 请求方式GET(HTTPS)
* 文档地址<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_intercept_rule_list">获取敏感词规则列表</a>
*
* @return WxCpInterceptRuleList 敏感词规则列表
* @throws WxErrorException 微信API异常
*/
WxCpInterceptRuleList getInterceptRuleList() throws WxErrorException;
/**
* 获取敏感词详情
*
* 企业和第三方应用可以通过此接口获取单个敏感词规则的详细信息
* 请求方式GET(HTTPS)
* 文档地址<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_intercept_rule">获取敏感词详情</a>
*
* @param ruleId 敏感词规则ID
* @return WxCpInterceptRuleInfo 敏感词规则详情
* @throws WxErrorException 微信API异常
*/
WxCpInterceptRuleInfo getInterceptRuleDetail(String ruleId) throws WxErrorException;
/** /**
* <pre> * <pre>
* 创建商品图册 * 创建商品图册

View File

@ -21,6 +21,8 @@ import me.chanjar.weixin.cp.bean.external.acquisition.*;
import me.chanjar.weixin.cp.bean.external.contact.*; import me.chanjar.weixin.cp.bean.external.contact.*;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleInfo;
import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleList;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -740,6 +742,19 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
GsonHelper.buildJsonObject("rule_id", ruleId)); GsonHelper.buildJsonObject("rule_id", ruleId));
} }
@Override
public WxCpInterceptRuleList getInterceptRuleList() throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_INTERCEPT_RULE_LIST);
return WxCpInterceptRuleList.fromJson(this.mainService.get(url,null));
}
@Override
public WxCpInterceptRuleInfo getInterceptRuleDetail(String ruleId) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_INTERCEPT_RULE);
String json = this.mainService.post(url, GsonHelper.buildJsonObject("rule_id", ruleId));
return WxCpInterceptRuleInfo.fromJson(json);
}
@Override @Override
public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException { public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM); String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM);

View File

@ -0,0 +1,58 @@
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.acquisition.WxCpCustomerAcquisitionInfo;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* @Date: 2024-03-07 17:02
* @Author shenliuming
* @return
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCpInterceptRuleInfo extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = -425957862453041229L;
@SerializedName("rule")
private Rule rule;
@Data
@EqualsAndHashCode(callSuper = false)
public static class Rule implements Serializable {
@SerializedName("rule_id")
private String ruleId;
@SerializedName("rule_name")
private String ruleName;
@SerializedName("word_list")
private List<String> wordList;
@SerializedName("semantics_list")
private List<Integer> semanticsList;
@SerializedName("intercept_type")
private Integer interceptType;
@SerializedName("applicable_range")
private ApplicableRange applicableRange;
@SerializedName("create_time")
private long createTime;
}
public static WxCpInterceptRuleInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleInfo.class);
}
}

View File

@ -0,0 +1,61 @@
package me.chanjar.weixin.cp.bean.external.interceptrule;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import me.chanjar.weixin.common.bean.ToJson;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.acquisition.WxCpCustomerAcquisitionInfo;
import me.chanjar.weixin.cp.bean.external.acquisition.WxCpCustomerAcquisitionList;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* @Date: 2024-03-07 15:54
* @Author shenliuming
* @return
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCpInterceptRuleList extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = -830298362453041229L;
/**
* link_id列表
*/
@SerializedName("rule_list")
private List<Rule> ruleList;
public static WxCpInterceptRuleList fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleList.class);
}
@Data
@EqualsAndHashCode(callSuper = false)
public static class Rule implements Serializable {
private static final long serialVersionUID = 4750537220968228300L;
/**
* 规则id
*/
@SerializedName("rule_id")
private String ruleId;
/**
* 规则名称长度上限20个字符
*/
@SerializedName("rule_name")
private String ruleName;
/**
* 创建时间
*/
@SerializedName("create_time")
private Long createTime;
public static WxCpInterceptRuleList.Rule fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpInterceptRuleList.Rule.class);
}
}
}

View File

@ -1344,6 +1344,14 @@ public interface WxCpApiPathConsts {
* The constant DEL_INTERCEPT_RULE. * The constant DEL_INTERCEPT_RULE.
*/ */
String DEL_INTERCEPT_RULE = "/cgi-bin/externalcontact/del_intercept_rule"; String DEL_INTERCEPT_RULE = "/cgi-bin/externalcontact/del_intercept_rule";
/**
* 获取敏感词规则列表
*/
String GET_INTERCEPT_RULE_LIST = "/cgi-bin/externalcontact/get_intercept_rule_list";
/**
* 获取敏感词规则详情
*/
String GET_INTERCEPT_RULE = "/cgi-bin/externalcontact/get_intercept_rule";
/** /**
* 获取当前仍然有效的获客链接 * 获取当前仍然有效的获客链接
*/ */