🆕 #2784【开放平台】增加批量代云开发之环境管理相关接口

This commit is contained in:
liming1019 2022-08-19 18:21:40 +08:00 committed by Binary Wang
parent 452dd58af9
commit c78a1f5132
9 changed files with 267 additions and 9 deletions

View File

@ -19,7 +19,7 @@ public interface WxMaShopOrderService {
WxMaShopBaseResponse orderPay(WxMaShopOrderPayRequest request) throws WxErrorException;
WxMaShopGetOrderResponse getOrder(Integer orderId, String outOrderId, String openid)
WxMaShopGetOrderResponse getOrder(Long orderId, String outOrderId, String openid)
throws WxErrorException;

View File

@ -56,7 +56,7 @@ public class WxMaShopOrderServiceImpl implements WxMaShopOrderService {
}
@Override
public WxMaShopGetOrderResponse getOrder(Integer orderId, String outOrderId, String openid) throws WxErrorException {
public WxMaShopGetOrderResponse getOrder(Long orderId, String outOrderId, String openid) throws WxErrorException {
return this.post(ORDER_GET, GsonHelper.buildJsonObject("order_id", orderId, "out_order_id", outOrderId,
"openid", openid), WxMaShopGetOrderResponse.class);
}

View File

@ -15,6 +15,10 @@ import me.chanjar.weixin.open.bean.minishop.coupon.WxMinishopCouponStock;
import me.chanjar.weixin.open.bean.minishop.goods.*;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
import me.chanjar.weixin.open.bean.result.*;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@ -130,9 +134,9 @@ public interface WxOpenComponentService {
*/
String FAST_REGISTER_PERSONAL_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?action=query";
/**
* 快速创建试用小程序接口.
*/
/**
* 快速创建试用小程序接口.
*/
String FAST_REGISTER_BETA_WEAPP_URL = "https://api.weixin.qq.com/wxa/component/fastregisterbetaweapp";
/**
@ -184,6 +188,13 @@ public interface WxOpenComponentService {
String MINISHOP_GET_DELIVERY_COMPANY_URL = "https://api.weixin.qq.com/product/delivery/get_company_list";
String BATCH_GET_ENVID_URL = "https://api.weixin.qq.com/componenttcb/batchgetenvid";
String DESCRIBE_ENVS_URL = "https://api.weixin.qq.com/componenttcb/describeenvs";
String MODIFY_ENV_URL = "https://api.weixin.qq.com/tcb/modifyenv";
String BATCH_SHARE_ENV = "https://api.weixin.qq.com/componenttcb/batchshareenv";
/**
* Gets wx mp service by appid.
@ -600,9 +611,9 @@ public interface WxOpenComponentService {
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
* 快速创建个人小程序
*
* @param idname 个人用户名字
* @param wxuser 个人用户微信号
* @param componentPhone 第三方联系电话
* @param idname 个人用户名字
* @param wxuser 个人用户微信号
* @param componentPhone 第三方联系电话
* @return the wx open result
* @throws WxErrorException
*/
@ -622,7 +633,7 @@ public interface WxOpenComponentService {
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastregister.html
* 注册试用小程序
*
* @param name 小程序名称
* @param name 小程序名称
* @param openid 微信用户的openid不是微信号
* @return the wx open result
* @throws WxErrorException
@ -1020,4 +1031,44 @@ public interface WxOpenComponentService {
* @return
*/
WxOpenResult updateLimitDiscountStatus(String appId, Long taskId, Integer status) throws WxErrorException;
/**
* 查询环境共享信息
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/getShareCloudbaseEnv.html
*
* @param appids 要查询的appid
* @return
*/
GetShareCloudBaseEnvResponse getShareCloudBaseEnv(List<String> appids) throws WxErrorException;
/**
* 获取环境信息
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/getTcbEnvList.html
*
* @return
* @throws WxErrorException
*/
GetTcbEnvListResponse getTcbEnvList() throws WxErrorException;
/**
* 转换云环境
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/changeTcbEnv.html
*
* @param env 环境id
* @return
* @throws WxErrorException
*/
WxOpenResult changeTcbEnv(String env) throws WxErrorException;
/**
* 环境共享
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/cloudbase-batch/env-mgnt/shareCloudbaseEnv.html
*
* @param request
* @return
* @throws WxErrorException
*/
ShareCloudBaseEnvResponse shareCloudBaseEnv(ShareCloudBaseEnvRequest request) throws WxErrorException;
}

View File

@ -1,6 +1,7 @@
package me.chanjar.weixin.open.api.impl;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
@ -28,6 +29,10 @@ import me.chanjar.weixin.open.bean.minishop.goods.*;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountGoods;
import me.chanjar.weixin.open.bean.minishop.limitdiscount.LimitDiscountSku;
import me.chanjar.weixin.open.bean.result.*;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
@ -1222,4 +1227,37 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public GetShareCloudBaseEnvResponse getShareCloudBaseEnv(List<String> appids) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
for(String appId : appids) {
jsonArray.add(appId);
}
jsonObject.add("appids", jsonArray);
String response = post(BATCH_GET_ENVID_URL, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, GetShareCloudBaseEnvResponse.class);
}
@Override
public GetTcbEnvListResponse getTcbEnvList() throws WxErrorException {
String response = post(DESCRIBE_ENVS_URL, new JsonObject().toString());
return WxOpenGsonBuilder.create().fromJson(response, GetTcbEnvListResponse.class);
}
@Override
public WxOpenResult changeTcbEnv(String env) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("env", env);
String response = post(MODIFY_ENV_URL, jsonObject.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
@Override
public ShareCloudBaseEnvResponse shareCloudBaseEnv(ShareCloudBaseEnvRequest request) throws WxErrorException {
Gson gson = new Gson();
String response = post(BATCH_SHARE_ENV, gson.toJson(request));
return WxOpenGsonBuilder.create().fromJson(response, ShareCloudBaseEnvResponse.class);
}
}

View File

@ -0,0 +1,32 @@
package me.chanjar.weixin.open.bean.tcb;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ShareCloudBaseEnvRequest implements Serializable {
private static final long serialVersionUID = 410566969624593042L;
@SerializedName("data")
private List<DataDTO> data;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class DataDTO implements Serializable {
@SerializedName("env")
private String env;
@SerializedName("appids")
private List<String> appids;
}
}

View File

@ -0,0 +1,28 @@
package me.chanjar.weixin.open.bean.tcb;
import com.google.gson.annotations.SerializedName;
import lombok.Builder;
import lombok.Data;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import java.io.Serializable;
import java.util.List;
@Data
@Builder
public class ShareCloudBaseEnvResponse extends WxOpenResult implements Serializable {
private static final long serialVersionUID = 316444074975118997L;
@SerializedName("err_list")
private List<ErrListDTO> errList;
@Data
public static class ErrListDTO implements Serializable {
@SerializedName("env")
private String env;
@SerializedName("appid")
private String appid;
@SerializedName("errmsg")
private String errmsg;
}
}

View File

@ -0,0 +1,35 @@
package me.chanjar.weixin.open.bean.tcbComponent;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import java.io.Serializable;
import java.util.List;
@Data
public class GetShareCloudBaseEnvResponse extends WxOpenResult implements Serializable {
private static final long serialVersionUID = -6267755285547585403L;
@SerializedName("relation_data")
private List<RelationDataDTO> relationData;
@SerializedName("err_list")
private List<ErrListDTO> errList;
@Data
public static class RelationDataDTO implements Serializable {
@SerializedName("appid")
private String appid;
@SerializedName("env_list")
private List<String> envList;
}
@Data
public static class ErrListDTO implements Serializable {
@SerializedName("appid")
private String appid;
@SerializedName("errmsg")
private String errmsg;
}
}

View File

@ -0,0 +1,38 @@
package me.chanjar.weixin.open.bean.tcbComponent;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import java.io.Serializable;
import java.util.List;
@Data
public class GetTcbEnvListResponse extends WxOpenResult implements Serializable {
private static final long serialVersionUID = -5896318347861752798L;
@SerializedName("info_list")
private List<InfoListDTO> infoList;
@Data
public static class InfoListDTO implements Serializable {
@SerializedName("env")
private String env;
@SerializedName("alias")
private String alias;
@SerializedName("create_time")
private String createTime;
@SerializedName("update_time")
private String updateTime;
@SerializedName("status")
private String status;
@SerializedName("package_id")
private String packageId;
@SerializedName("package_name")
private String packageName;
@SerializedName("dbinstance_id")
private String dbinstanceId;
@SerializedName("bucket_id")
private String bucketId;
}
}

View File

@ -3,10 +3,18 @@ package me.chanjar.weixin.open.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenComponentService;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetShareCloudBaseEnvResponse;
import me.chanjar.weixin.open.bean.tcbComponent.GetTcbEnvListResponse;
import me.chanjar.weixin.open.test.ApiTestModule;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.Arrays;
/**
* 单元测试类.
*
@ -171,4 +179,32 @@ public class WxOpenComponentServiceImplTest {
public void testStartPushTicket() throws WxErrorException {
wxOpenComponentService.startPushTicket();
}
@Test
public void testGetShareCloudBaseEnv() throws WxErrorException {
GetShareCloudBaseEnvResponse response = wxOpenComponentService.getShareCloudBaseEnv(Arrays.asList("wxad2ee6fa2df2c46d"));
Assert.assertNotNull(response);
}
@Test
public void testGetTcbEnvListv() throws WxErrorException {
GetTcbEnvListResponse response = wxOpenComponentService.getTcbEnvList();
Assert.assertNotNull(response);
}
@Test
public void testChangeTcbEnv() throws WxErrorException {
WxOpenResult response = wxOpenComponentService.changeTcbEnv("test");
Assert.assertNotNull(response);
}
@Test
public void testShareCloudBaseEnv() throws WxErrorException {
ShareCloudBaseEnvRequest request = ShareCloudBaseEnvRequest.builder()
.data(Arrays.asList(ShareCloudBaseEnvRequest.DataDTO.builder()
.env("test-env-6gni9ity244a6ea3").appids(Arrays.asList("wx5fe6bb43205e9e07")).build()))
.build();
ShareCloudBaseEnvResponse response = wxOpenComponentService.shareCloudBaseEnv(request);
Assert.assertNotNull(response);
}
}