mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 02:28:25 +08:00 
			
		
		
		
	🆕 #1895 【小程序】直播增加成员管理相关接口
This commit is contained in:
		| @ -0,0 +1,55 @@ | |||||||
|  | package cn.binarywang.wx.miniapp.api; | ||||||
|  |  | ||||||
|  | import com.google.gson.JsonArray; | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 【小程序直播】成员管理接口. | ||||||
|  |  * https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/role-manage.html | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  |  * @date 2021 -02-15 | ||||||
|  |  */ | ||||||
|  | public interface WxMaLiveMemberService { | ||||||
|  |   /** | ||||||
|  |    * 1.设置成员角色 | ||||||
|  |    * 调用此接口设置小程序直播成员的管理员、运营者和主播角色 | ||||||
|  |    * 调用额度:10000次/一天 | ||||||
|  |    * 请求URL : https://api.weixin.qq.com/wxaapi/broadcast/role/addrole?access_token= | ||||||
|  |    * | ||||||
|  |    * @param username 用户的微信号 | ||||||
|  |    * @param role     设置用户的角色,取值[1-管理员,2-主播,3-运营者],设置超级管理员将无效 | ||||||
|  |    * @return the string | ||||||
|  |    * @throws WxErrorException the wx error exception | ||||||
|  |    */ | ||||||
|  |   String addRole(String username, int role) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 2.解除成员角色 | ||||||
|  |    * 调用此接口移除小程序直播成员的管理员、运营者和主播角色 | ||||||
|  |    * 调用额度:10000次/一天 | ||||||
|  |    * 请求URL:https://api.weixin.qq.com/wxaapi/broadcast/role/deleterole?access_token= | ||||||
|  |    * | ||||||
|  |    * @param username 用户的微信号 | ||||||
|  |    * @param role     设置用户的角色,取值[1-管理员,2-主播,3-运营者],设置超级管理员将无效 | ||||||
|  |    * @return the string | ||||||
|  |    * @throws WxErrorException the wx error exception | ||||||
|  |    */ | ||||||
|  |   String deleteRole(String username, int role) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 3.查询成员列表 | ||||||
|  |    * 调用此接口查询小程序直播成员列表 | ||||||
|  |    * 调用额度:10000次/一天 | ||||||
|  |    * 请求URL:https://api.weixin.qq.com/wxaapi/broadcast/role/getrolelist?access_token= | ||||||
|  |    * | ||||||
|  |    * @param role    查询的用户角色,取值 [-1-所有成员, 0-超级管理员,1-管理员,2-主播,3-运营者],默认-1 | ||||||
|  |    * @param offset  起始偏移量, 默认0 | ||||||
|  |    * @param limit   查询个数,最大30,默认10 | ||||||
|  |    * @param keyword 搜索的微信号或昵称,不传则返回全部 | ||||||
|  |    * @return . json array | ||||||
|  |    * @throws WxErrorException the wx error exception | ||||||
|  |    */ | ||||||
|  |   JsonArray listByRole(Integer role, Integer offset, Integer limit, String keyword) throws WxErrorException; | ||||||
|  | } | ||||||
| @ -356,6 +356,13 @@ public interface WxMaService extends WxService { | |||||||
|    */ |    */ | ||||||
|   WxMaLiveGoodsService getLiveGoodsService(); |   WxMaLiveGoodsService getLiveGoodsService(); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 获取直播成员管理接口服务对象 | ||||||
|  |    * | ||||||
|  |    * @return . live service | ||||||
|  |    */ | ||||||
|  |   WxMaLiveMemberService getLiveMemberService(); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 获取ocr实现接口服务对象 |    * 获取ocr实现接口服务对象 | ||||||
|    * |    * | ||||||
|  | |||||||
| @ -60,6 +60,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH | |||||||
|   private final WxMaCloudService cloudService = new WxMaCloudServiceImpl(this); |   private final WxMaCloudService cloudService = new WxMaCloudServiceImpl(this); | ||||||
|   private final WxMaLiveService liveService = new WxMaLiveServiceImpl(this); |   private final WxMaLiveService liveService = new WxMaLiveServiceImpl(this); | ||||||
|   private final WxMaLiveGoodsService liveGoodsService = new WxMaLiveGoodsServiceImpl(this); |   private final WxMaLiveGoodsService liveGoodsService = new WxMaLiveGoodsServiceImpl(this); | ||||||
|  |   private final WxMaLiveMemberService liveMemberService = new WxMaLiveMemberServiceImpl(this); | ||||||
|   private final WxOcrService ocrService = new WxMaOcrServiceImpl(this); |   private final WxOcrService ocrService = new WxMaOcrServiceImpl(this); | ||||||
|   private final WxImgProcService imgProcService = new WxMaImgProcServiceImpl(this); |   private final WxImgProcService imgProcService = new WxMaImgProcServiceImpl(this); | ||||||
|   private Map<String, WxMaConfig> configMap; |   private Map<String, WxMaConfig> configMap; | ||||||
| @ -483,6 +484,11 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH | |||||||
|     return this.liveGoodsService; |     return this.liveGoodsService; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public WxMaLiveMemberService getLiveMemberService() { | ||||||
|  |     return this.liveMemberService; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxOcrService getOcrService() { |   public WxOcrService getOcrService() { | ||||||
|     return this.ocrService; |     return this.ocrService; | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ import com.google.gson.JsonArray; | |||||||
| import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import me.chanjar.weixin.common.util.json.GsonHelper; | ||||||
| import me.chanjar.weixin.common.util.json.GsonParser; | import me.chanjar.weixin.common.util.json.GsonParser; | ||||||
|  |  | ||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
| @ -18,7 +19,7 @@ import java.util.HashMap; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.LiveGoods.*; | import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Goods.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * <pre> |  * <pre> | ||||||
| @ -34,32 +35,26 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService { | |||||||
|   @Override |   @Override | ||||||
|   public WxMaLiveResult addGoods(WxMaLiveGoodInfo goods) throws WxErrorException { |   public WxMaLiveResult addGoods(WxMaLiveGoodInfo goods) throws WxErrorException { | ||||||
|     return WxMaLiveResult.fromJson(this.wxMaService.post(ADD_GOODS, |     return WxMaLiveResult.fromJson(this.wxMaService.post(ADD_GOODS, | ||||||
|       WxMaGsonBuilder.create().toJson(ImmutableMap.of("goodsInfo", goods)))); |       GsonHelper.buildJsonObject("goodsInfo", goods))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public boolean resetAudit(Integer auditId, Integer goodsId) throws WxErrorException { |   public boolean resetAudit(Integer auditId, Integer goodsId) throws WxErrorException { | ||||||
|     Map<String, Integer> map = new HashMap<>(4); |     this.wxMaService.post(RESET_AUDIT_GOODS, | ||||||
|     map.put("auditId", auditId); |       GsonHelper.buildJsonObject("auditId", auditId, "goodsId", goodsId)); | ||||||
|     map.put("goodsId", goodsId); |  | ||||||
|     this.wxMaService.post(RESET_AUDIT_GOODS, WxMaGsonBuilder.create().toJson(map)); |  | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public String auditGoods(Integer goodsId) throws WxErrorException { |   public String auditGoods(Integer goodsId) throws WxErrorException { | ||||||
|     Map<String, Integer> map = new HashMap<>(2); |     String responseContent = this.wxMaService.post(AUDIT_GOODS, | ||||||
|     map.put("goodsId", goodsId); |       GsonHelper.buildJsonObject("goodsId", goodsId)); | ||||||
|     String responseContent = this.wxMaService.post(AUDIT_GOODS, WxMaGsonBuilder.create().toJson(map)); |     return GsonParser.parse(responseContent).get("auditId").getAsString(); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |  | ||||||
|     return jsonObject.get("auditId").getAsString(); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public boolean deleteGoods(Integer goodsId) throws WxErrorException { |   public boolean deleteGoods(Integer goodsId) throws WxErrorException { | ||||||
|     Map<String, Integer> map = new HashMap<>(2); |     this.wxMaService.post(DELETE_GOODS, GsonHelper.buildJsonObject("goodsId", goodsId)); | ||||||
|     map.put("goodsId", goodsId); |  | ||||||
|     this.wxMaService.post(DELETE_GOODS, WxMaGsonBuilder.create().toJson(map)); |  | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -0,0 +1,42 @@ | |||||||
|  | package cn.binarywang.wx.miniapp.api.impl; | ||||||
|  |  | ||||||
|  | import cn.binarywang.wx.miniapp.api.WxMaLiveMemberService; | ||||||
|  | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||||
|  | import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Role; | ||||||
|  | import com.google.gson.JsonArray; | ||||||
|  | import lombok.RequiredArgsConstructor; | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import me.chanjar.weixin.common.util.json.GsonHelper; | ||||||
|  | import me.chanjar.weixin.common.util.json.GsonParser; | ||||||
|  |  | ||||||
|  | import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Role.LIST_BY_ROLE; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * . | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  |  * @date 2021-02-15 | ||||||
|  |  */ | ||||||
|  | @RequiredArgsConstructor | ||||||
|  | public class WxMaLiveMemberServiceImpl implements WxMaLiveMemberService { | ||||||
|  |   private final WxMaService service; | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public String addRole(String username, int role) throws WxErrorException { | ||||||
|  |     return this.service.post(Role.ADD_ROLE, | ||||||
|  |       GsonHelper.buildJsonObject("username", username, "role", role)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public String deleteRole(String username, int role) throws WxErrorException { | ||||||
|  |     return this.service.post(Role.DELETE_ROLE, | ||||||
|  |       GsonHelper.buildJsonObject("username", username, "role", role)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public JsonArray listByRole(Integer role, Integer offset, Integer limit, String keyword) throws WxErrorException { | ||||||
|  |     final String response = this.service.get(LIST_BY_ROLE, GsonHelper.buildJsonObject("role", role, "offset", offset, | ||||||
|  |       "limit", limit, "keyword", keyword).toString()); | ||||||
|  |     return GsonParser.parse(response).getAsJsonArray("list"); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -18,7 +18,7 @@ import java.util.HashMap; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Live.*; | import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * <pre> |  * <pre> | ||||||
| @ -36,7 +36,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxMaCreateRoomResult createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException { |   public WxMaCreateRoomResult createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException { | ||||||
|     String responseContent = this.wxMaService.post(CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo)); |     String responseContent = this.wxMaService.post(Room.CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -49,7 +49,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|   public boolean deleteRoom(Integer roomId) throws WxErrorException { |   public boolean deleteRoom(Integer roomId) throws WxErrorException { | ||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put("id", roomId); |     map.put("id", roomId); | ||||||
|     String responseContent = this.wxMaService.post(DELETE_ROOM, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.DELETE_ROOM, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -59,7 +59,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public boolean editRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException { |   public boolean editRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException { | ||||||
|     String responseContent = this.wxMaService.post(EDIT_ROOM, WxMaGsonBuilder.create().toJson(roomInfo)); |     String responseContent = this.wxMaService.post(Room.EDIT_ROOM, WxMaGsonBuilder.create().toJson(roomInfo)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -71,7 +71,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|   public String getPushUrl(Integer roomId) throws WxErrorException { |   public String getPushUrl(Integer roomId) throws WxErrorException { | ||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     String responseContent = this.wxMaService.get(GET_PUSH_URL, Joiner.on("&").withKeyValueSeparator("=").join(map)); |     String responseContent = this.wxMaService.get(Room.GET_PUSH_URL, Joiner.on("&").withKeyValueSeparator("=").join(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -86,7 +86,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|     if (null != params) { |     if (null != params) { | ||||||
|       map.put("params", params); |       map.put("params", params); | ||||||
|     } |     } | ||||||
|     String responseContent = this.wxMaService.get(GET_SHARED_CODE, Joiner.on("&").withKeyValueSeparator("=").join(map)); |     String responseContent = this.wxMaService.get(Room.GET_SHARED_CODE, Joiner.on("&").withKeyValueSeparator("=").join(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -162,7 +162,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     map.put("ids", goodsIds); |     map.put("ids", goodsIds); | ||||||
|     String responseContent = this.wxMaService.post(ADD_GOODS, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.ADD_GOODS, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -175,7 +175,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     map.put("users", users); |     map.put("users", users); | ||||||
|     String responseContent = this.wxMaService.post(ADD_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.ADD_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -189,7 +189,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     map.put("username", username); |     map.put("username", username); | ||||||
|     map.put("nickname", nickname); |     map.put("nickname", nickname); | ||||||
|     String responseContent = this.wxMaService.post(MODIFY_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.MODIFY_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -202,7 +202,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     map.put("username", username); |     map.put("username", username); | ||||||
|     String responseContent = this.wxMaService.post(REMOVE_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.REMOVE_ASSISTANT, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
| @ -214,7 +214,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService { | |||||||
|   public List<WxMaAssistantResult.Assistant> getAssistantList(Integer roomId) throws WxErrorException { |   public List<WxMaAssistantResult.Assistant> getAssistantList(Integer roomId) throws WxErrorException { | ||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|     map.put(ROOM_ID, roomId); |     map.put(ROOM_ID, roomId); | ||||||
|     String responseContent = this.wxMaService.post(GET_ASSISTANT_LIST, WxMaGsonBuilder.create().toJson(map)); |     String responseContent = this.wxMaService.post(Room.GET_ASSISTANT_LIST, WxMaGsonBuilder.create().toJson(map)); | ||||||
|     JsonObject jsonObject = GsonParser.parse(responseContent); |     JsonObject jsonObject = GsonParser.parse(responseContent); | ||||||
|     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |     if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |       throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||||||
|  | |||||||
| @ -157,18 +157,13 @@ public class WxMaApiUrlConstants { | |||||||
|     String GET_JSAPI_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"; |     String GET_JSAPI_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   public interface LiveGoods { |   public interface Broadcast { | ||||||
|     String ADD_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add"; |  | ||||||
|     String RESET_AUDIT_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit"; |  | ||||||
|     String AUDIT_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/audit"; |  | ||||||
|     String DELETE_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete"; |  | ||||||
|     String UPDATE_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update"; |  | ||||||
|     String GET_GOODS_WARE_HOUSE = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse"; |  | ||||||
|     String GET_APPROVED_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved"; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   public interface Live { |  | ||||||
|     String GET_LIVE_INFO = "https://api.weixin.qq.com/wxa/business/getliveinfo"; |     String GET_LIVE_INFO = "https://api.weixin.qq.com/wxa/business/getliveinfo"; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 直播间管理相关接口 | ||||||
|  |      */ | ||||||
|  |     interface Room { | ||||||
|       String CREATE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/create"; |       String CREATE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/create"; | ||||||
|       String ADD_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods"; |       String ADD_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods"; | ||||||
|       String DELETE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom"; |       String DELETE_ROOM = "https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom"; | ||||||
| @ -181,6 +176,29 @@ public class WxMaApiUrlConstants { | |||||||
|       String GET_ASSISTANT_LIST = "https://api.weixin.qq.com/wxaapi/broadcast/room/getassistantlist"; |       String GET_ASSISTANT_LIST = "https://api.weixin.qq.com/wxaapi/broadcast/room/getassistantlist"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 直播商品管理相关接口 | ||||||
|  |      */ | ||||||
|  |     interface Goods { | ||||||
|  |       String ADD_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add"; | ||||||
|  |       String RESET_AUDIT_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit"; | ||||||
|  |       String AUDIT_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/audit"; | ||||||
|  |       String DELETE_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete"; | ||||||
|  |       String UPDATE_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update"; | ||||||
|  |       String GET_GOODS_WARE_HOUSE = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse"; | ||||||
|  |       String GET_APPROVED_GOODS = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved"; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 小程序直播成员管理接口 | ||||||
|  |      */ | ||||||
|  |     interface Role { | ||||||
|  |       String ADD_ROLE = "https://api.weixin.qq.com/wxaapi/broadcast/role/addrole"; | ||||||
|  |       String DELETE_ROLE = "https://api.weixin.qq.com/wxaapi/broadcast/role/deleterole"; | ||||||
|  |       String LIST_BY_ROLE = "https://api.weixin.qq.com/wxaapi/broadcast/role/getrolelist"; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public interface Media { |   public interface Media { | ||||||
|     String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?type=%s"; |     String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?type=%s"; | ||||||
|     String MEDIA_GET_URL = "https://api.weixin.qq.com/cgi-bin/media/get"; |     String MEDIA_GET_URL = "https://api.weixin.qq.com/cgi-bin/media/get"; | ||||||
|  | |||||||
| @ -0,0 +1,40 @@ | |||||||
|  | package cn.binarywang.wx.miniapp.api.impl; | ||||||
|  |  | ||||||
|  | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||||
|  | import cn.binarywang.wx.miniapp.test.ApiTestModule; | ||||||
|  | import com.google.gson.JsonArray; | ||||||
|  | import com.google.inject.Inject; | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import org.testng.annotations.Guice; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 测试. | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  |  * @date 2021-02-15 | ||||||
|  |  */ | ||||||
|  | @Test | ||||||
|  | @Guice(modules = ApiTestModule.class) | ||||||
|  | public class WxMaLiveMemberServiceImplTest { | ||||||
|  |   @Inject | ||||||
|  |   private WxMaService wxService; | ||||||
|  |  | ||||||
|  |   @Test | ||||||
|  |   public void testAddRole() throws WxErrorException { | ||||||
|  |     final String result = this.wxService.getLiveMemberService().addRole("abc", 1); | ||||||
|  |     System.out.println(result); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @Test | ||||||
|  |   public void testDeleteRole() throws WxErrorException { | ||||||
|  |     final String result = this.wxService.getLiveMemberService().deleteRole("abc", 1); | ||||||
|  |     System.out.println(result); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @Test | ||||||
|  |   public void testListByRole() throws WxErrorException { | ||||||
|  |     final JsonArray result = this.wxService.getLiveMemberService().listByRole(null, null, null, null); | ||||||
|  |     System.out.println(result); | ||||||
|  |   } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang