mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🆕 #2856 【企业微信】增加获取应用二维码的接口;【开放平台】增加使用 AppSecret 重置第三方平台 API 调用次数的接口
This commit is contained in:
parent
46921e0e55
commit
edb098500d
@ -0,0 +1,35 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 应用的管理员
|
||||
*
|
||||
* @author huangxiaoming
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxCpTpAppQrcode extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
@SerializedName("qrcode")
|
||||
private String qrcode;
|
||||
|
||||
/**
|
||||
* From json wx cp tp admin.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp tp admin
|
||||
*/
|
||||
public static WxCpTpAppQrcode fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpAppQrcode.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 应用的管理员
|
||||
*
|
||||
* @author huangxiaoming
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxCpTpCorpId2OpenCorpId extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
@SerializedName("open_corpid")
|
||||
private String openCorpId;
|
||||
|
||||
/**
|
||||
* From json wx cp tp admin.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp tp admin
|
||||
*/
|
||||
public static WxCpTpCorpId2OpenCorpId fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpCorpId2OpenCorpId.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -795,6 +795,15 @@ public interface WxCpApiPathConsts {
|
||||
* The constant GET_ADMIN_LIST.
|
||||
*/
|
||||
String GET_ADMIN_LIST = "/cgi-bin/service/get_admin_list";
|
||||
/**
|
||||
* The constant GET_APP_QRCODE.
|
||||
*/
|
||||
String GET_APP_QRCODE = "/cgi-bin/service/get_app_qrcode";
|
||||
|
||||
/**
|
||||
* The constant CORPID_TO_OPENCORPID.
|
||||
*/
|
||||
String CORPID_TO_OPENCORPID = "/cgi-bin/service/corpid_to_opencorpid";
|
||||
|
||||
/**
|
||||
* The constant GET_ORDER.
|
||||
|
@ -525,6 +525,28 @@ public interface WxCpTpService {
|
||||
*/
|
||||
WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取应用二维码
|
||||
* @param suiteId 第三方应用id(即ww或wx开头的suiteid)
|
||||
* @param appId 第三方应用id,单应用不需要该参数,多应用旧套件才需要传该参数。若不传默认为1
|
||||
* @param state state值,用于区分不同的安装渠道
|
||||
* @param style 二维码样式选项,默认为不带说明外框小尺寸。0:带说明外框的二维码,适合于实体物料,1:带说明外框的二维码,适合于屏幕类,2:不带说明外框(小尺寸),3:不带说明外框(中尺寸),4:不带说明外框(大尺寸)。具体样式与服务商管理端获取到的应用二维码样式一一对应,参见下文二维码样式说明
|
||||
* @param resultType 结果返回方式,默认为返回二维码图片buffer。1:二维码图片buffer,2:二维码图片url
|
||||
* @return 二维码
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException ;
|
||||
|
||||
/**
|
||||
*
|
||||
* 明文corpid转换为加密corpid 为更好地保护企业与用户的数据,第三方应用获取的corpid不再是明文的corpid,将升级为第三方服务商级别的加密corpid。<a href="https://developer.work.weixin.qq.com/document/path/95327">文档说明</a>
|
||||
* 第三方可以将已有的明文corpid转换为第三方的加密corpid。
|
||||
* @param corpId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 创建机构级jsApiTicket签名
|
||||
* 详情参见企业微信第三方应用开发文档:https://work.weixin.qq.com/api/doc/90001/90144/90539
|
||||
|
@ -654,6 +654,24 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
return WxCpTpAdmin.fromJson(result);
|
||||
}
|
||||
|
||||
public WxCpTpAppQrcode getAppQrcode(String suiteId, String appId, String state, Integer style, Integer resultType) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("suite_id", suiteId);
|
||||
jsonObject.addProperty("appid", appId);
|
||||
jsonObject.addProperty("state", state);
|
||||
jsonObject.addProperty("style", style);
|
||||
jsonObject.addProperty("result_type", resultType);
|
||||
String result = post(configStorage.getApiUrl(GET_APP_QRCODE), jsonObject.toString());
|
||||
return WxCpTpAppQrcode.fromJson(result);
|
||||
}
|
||||
|
||||
public WxCpTpCorpId2OpenCorpId corpId2OpenCorpId(String corpId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
String result = post(configStorage.getApiUrl(CORPID_TO_OPENCORPID) +"?provider_access_token=" + this.configStorage.getAccessToken(corpId), jsonObject.toString());
|
||||
return WxCpTpCorpId2OpenCorpId.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxJsapiSignature createAuthCorpJsApiTicketSignature(String url, String authCorpId) throws WxErrorException {
|
||||
return doCreateWxJsapiSignature(url, authCorpId, this.getAuthCorpJsApiTicket(authCorpId));
|
||||
|
@ -4,6 +4,7 @@ import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.redis.RedissonWxRedisOps;
|
||||
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpCorpId2OpenCorpId;
|
||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
import me.chanjar.weixin.cp.config.impl.WxCpTpRedissonConfigImpl;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
@ -178,4 +179,10 @@ public class WxCpTpServiceApacheHttpClientImplTest {
|
||||
suiteJsApiTicket = wxCpTpService.getSuiteJsApiTicket(AUTH_CORP_ID);
|
||||
System.out.println("suiteJsApiTicket:" + suiteJsApiTicket);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorpId2OpenCorpId() throws WxErrorException {
|
||||
WxCpTpCorpId2OpenCorpId openCorpId = wxCpTpService.corpId2OpenCorpId("wpVIkfEAAAu2wGiOEeNMQ69afwLM6BbA");
|
||||
System.out.println("openCorpId:" + openCorpId);
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,7 @@ public interface WxOpenComponentService {
|
||||
|
||||
String BATCH_SHARE_ENV = "https://api.weixin.qq.com/componenttcb/batchshareenv";
|
||||
|
||||
String COMPONENT_CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2";
|
||||
/**
|
||||
* Gets wx mp service by appid.
|
||||
*
|
||||
@ -1085,4 +1086,15 @@ public interface WxOpenComponentService {
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
ShareCloudBaseEnvResponse shareCloudBaseEnv(ShareCloudBaseEnvRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 使用 AppSecret 重置第三方平台 API 调用次数
|
||||
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/openapi/clearComponentQuotaByAppSecret.html
|
||||
*
|
||||
* @param appid 授权用户appid
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult clearQuotaV2(String appid) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -1265,4 +1265,14 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = post(BATCH_SHARE_ENV, gson.toJson(request));
|
||||
return WxOpenGsonBuilder.create().fromJson(response, ShareCloudBaseEnvResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult clearQuotaV2(String appid) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("appid", appid);
|
||||
jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
|
||||
jsonObject.addProperty("appsecret", getWxOpenConfigStorage().getComponentAppSecret());
|
||||
String response = getWxOpenService().post(COMPONENT_CLEAR_QUOTA_URL, jsonObject.toString());
|
||||
return WxOpenResult.fromJson(response);
|
||||
}
|
||||
}
|
||||
|
@ -213,4 +213,11 @@ public class WxOpenComponentServiceImplTest {
|
||||
ShareCloudBaseEnvResponse response = wxOpenComponentService.shareCloudBaseEnv(request);
|
||||
Assert.assertNotNull(response);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testClearQuotaV2() throws WxErrorException {
|
||||
WxOpenResult wxOpenResult = wxOpenComponentService.clearQuotaV2("");
|
||||
Assert.assertNotNull(wxOpenResult);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user