Skip to content

Commit

Permalink
🆕 #2613【企业微信】增加管理商品图册的相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjun96 authored Apr 24, 2022
1 parent 1030115 commit 8831056
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package me.chanjar.weixin.cp.api;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import lombok.NonNull;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.*;
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalInfoQueryFilter;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -977,7 +976,8 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_intercept_rule?access_token=ACCESS_TOKEN
* <pre>
*/
WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;
WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;

/**
* <pre>
* 删除敏感词规则
Expand All @@ -987,6 +987,42 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* <pre>
* @param rule_id 规则id
*/
WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException;
WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException;

/**
* <pre>
* 创建商品图册
* 企业和第三方应用可以通过此接口增加商品
* 请求方式:POST(HTTPS)
* 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
* <pre>
* @param wxCpProductAlbumInfo 商品图册信息
* @return 商品id
*/
String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;

/**
* <pre>
* 编辑商品图册
* 企业和第三方应用可以通过此接口修改商品信息
* 请求方式:POST(HTTPS)
* 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
* <pre>
* @param wxCpProductAlbumInfo 商品图册信息
*/
void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;

/**
* <pre>
* 删除商品图册
* 企业和第三方应用可以通过此接口删除商品信息
* 请求方式:POST(HTTPS)
* 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN</a>
* 文档地址:<a href="https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C">https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C</a>
* <pre>
* @param productId 商品id
*/
void deleteProductAlbum(String productId) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.JsonObject;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;

import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
Expand All @@ -27,9 +21,13 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*;

Expand Down Expand Up @@ -857,10 +855,32 @@ public WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp rul
@Override
public WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("rule_id",rule_id);
jsonObject.addProperty("rule_id", rule_id);
return WxCpBaseResp
.fromJson(this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(DEL_INTERCEPT_RULE), jsonObject));
}

@Override
public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM);
String responseContent = this.mainService.post(url, wxCpProductAlbumInfo.toJson());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("product_id").getAsString();
}

@Override
public void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_PRODUCT_ALBUM);
this.mainService.post(url, wxCpProductAlbumInfo.toJson());
}

@Override
public void deleteProductAlbum(String productId) throws WxErrorException {
JsonObject o = new JsonObject();
o.addProperty("product_id", productId);
String url = this.mainService.getWxCpConfigStorage().getApiUrl(DELETE_PRODUCT_ALBUM);
this.mainService.post(url, o.toString());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public static WxCpProductAlbumInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumInfo.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,12 @@ interface ExternalContact {
String GET_GROUP_MSG_LIST_V2 = "/cgi-bin/externalcontact/get_groupmsg_list_v2";
String GET_GROUP_MSG_RESULT = "/cgi-bin/externalcontact/get_group_msg_result";


String GET_PRODUCT_ALBUM = "/cgi-bin/externalcontact/get_product_album";
String GET_PRODUCT_ALBUM_LIST = "/cgi-bin/externalcontact/get_product_album_list";
String ADD_PRODUCT_ALBUM = "/cgi-bin/externalcontact/add_product_album";
String UPDATE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/update_product_album";
String DELETE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/delete_product_album";

String GROUP_WELCOME_TEMPLATE_ADD = "/cgi-bin/externalcontact/group_welcome_template/add";
String GROUP_WELCOME_TEMPLATE_EDIT = "/cgi-bin/externalcontact/group_welcome_template/edit";
Expand Down

0 comments on commit 8831056

Please sign in to comment.