2
2
3
3
import cn .binarywang .wx .miniapp .api .WxMaLiveService ;
4
4
import cn .binarywang .wx .miniapp .api .WxMaService ;
5
+ import cn .binarywang .wx .miniapp .bean .live .WxMaAssistantResult ;
6
+ import cn .binarywang .wx .miniapp .bean .live .WxMaLiveAssistantInfo ;
5
7
import cn .binarywang .wx .miniapp .bean .live .WxMaLiveResult ;
6
8
import cn .binarywang .wx .miniapp .bean .live .WxMaLiveRoomInfo ;
7
9
import cn .binarywang .wx .miniapp .util .json .WxMaGsonBuilder ;
@@ -90,12 +92,6 @@ public String getSharedCode(Integer roomId, String params) throws WxErrorExcepti
90
92
return jsonObject .get ("cdnUrl" ).getAsString ();
91
93
}
92
94
93
- @ Override
94
- public WxMaLiveResult getLiveInfo (Integer start , Integer limit ) throws WxErrorException {
95
- JsonObject jsonObject = getLiveInfo (start , limit , null );
96
- return WxMaLiveResult .fromJson (jsonObject .toString ());
97
- }
98
-
99
95
@ Override
100
96
public List <WxMaLiveResult .RoomInfo > getLiveInfos () throws WxErrorException {
101
97
List <WxMaLiveResult .RoomInfo > results = new ArrayList <>();
@@ -124,6 +120,13 @@ public List<WxMaLiveResult.RoomInfo> getLiveInfos() throws WxErrorException {
124
120
return results ;
125
121
}
126
122
123
+ @ Override
124
+ public WxMaLiveResult getLiveInfo (Integer start , Integer limit ) throws WxErrorException {
125
+ JsonObject jsonObject = getLiveInfo (start , limit , null );
126
+ return WxMaLiveResult .fromJson (jsonObject .toString ());
127
+ }
128
+
129
+
127
130
@ Override
128
131
public WxMaLiveResult getLiveReplay (String action , Integer roomId , Integer start , Integer limit ) throws WxErrorException {
129
132
Map <String , Object > map = new HashMap <>(4 );
@@ -132,7 +135,19 @@ public WxMaLiveResult getLiveReplay(String action, Integer roomId, Integer start
132
135
JsonObject jsonObject = getLiveInfo (start , limit , map );
133
136
return WxMaLiveResult .fromJson (jsonObject .toString ());
134
137
}
135
-
138
+ private JsonObject getLiveInfo (Integer start , Integer limit , Map <String , Object > map ) throws WxErrorException {
139
+ if (map == null ) {
140
+ map = new HashMap (2 );
141
+ }
142
+ map .put ("start" , start );
143
+ map .put ("limit" , limit );
144
+ String responseContent = wxMaService .post (GET_LIVE_INFO , WxMaGsonBuilder .create ().toJson (map ));
145
+ JsonObject jsonObject = GsonParser .parse (responseContent );
146
+ if (jsonObject .get ("errcode" ).getAsInt () != 0 ) {
147
+ throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
148
+ }
149
+ return jsonObject ;
150
+ }
136
151
@ Override
137
152
public WxMaLiveResult getLiveReplay (Integer roomId , Integer start , Integer limit ) throws WxErrorException {
138
153
return getLiveReplay ("get_replay" , roomId , start , limit );
@@ -151,17 +166,57 @@ public boolean addGoodsToRoom(Integer roomId, List<Integer> goodsIds) throws WxE
151
166
return true ;
152
167
}
153
168
154
- private JsonObject getLiveInfo (Integer start , Integer limit , Map <String , Object > map ) throws WxErrorException {
155
- if (map == null ) {
156
- map = new HashMap (2 );
169
+ @ Override
170
+ public boolean addAssistant (Integer roomId , List <WxMaLiveAssistantInfo > users ) throws WxErrorException {
171
+ Map <String , Object > map = new HashMap <>(2 );
172
+ map .put ("roomId" , roomId );
173
+ map .put ("users" , users );
174
+ String responseContent = this .wxMaService .post (ADD_ASSISTANT , WxMaGsonBuilder .create ().toJson (map ));
175
+ JsonObject jsonObject = GsonParser .parse (responseContent );
176
+ if (jsonObject .get ("errcode" ).getAsInt () != 0 ) {
177
+ throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
157
178
}
158
- map .put ("start" , start );
159
- map .put ("limit" , limit );
160
- String responseContent = wxMaService .post (GET_LIVE_INFO , WxMaGsonBuilder .create ().toJson (map ));
179
+ return true ;
180
+ }
181
+
182
+ @ Override
183
+ public boolean modifyAssistant (Integer roomId , String username ,String nickname ) throws WxErrorException {
184
+ Map <String , Object > map = new HashMap <>(2 );
185
+ map .put ("roomId" , roomId );
186
+ map .put ("username" ,username );
187
+ map .put ("nickname" , nickname );
188
+ String responseContent = this .wxMaService .post (MODIFY_ASSISTANT , WxMaGsonBuilder .create ().toJson (map ));
161
189
JsonObject jsonObject = GsonParser .parse (responseContent );
162
190
if (jsonObject .get ("errcode" ).getAsInt () != 0 ) {
163
191
throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
164
192
}
165
- return jsonObject ;
193
+ return true ;
194
+ }
195
+
196
+ @ Override
197
+ public boolean removeAssistant (Integer roomId ,String username ) throws WxErrorException {
198
+ Map <String , Object > map = new HashMap <>(2 );
199
+ map .put ("roomId" , roomId );
200
+ map .put ("username" ,username );
201
+ String responseContent = this .wxMaService .post (REMOVE_ASSISTANT , WxMaGsonBuilder .create ().toJson (map ));
202
+ JsonObject jsonObject = GsonParser .parse (responseContent );
203
+ if (jsonObject .get ("errcode" ).getAsInt () != 0 ) {
204
+ throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
205
+ }
206
+ return true ;
166
207
}
208
+
209
+ @ Override
210
+ public List <WxMaAssistantResult .Assistant > getAssistantList (Integer roomId ) throws WxErrorException {
211
+ Map <String , Object > map = new HashMap <>(2 );
212
+ map .put ("roomId" , roomId );
213
+ String responseContent = this .wxMaService .post (GET_ASSISTANT_LIST , WxMaGsonBuilder .create ().toJson (map ));
214
+ JsonObject jsonObject = GsonParser .parse (responseContent );
215
+ if (jsonObject .get ("errcode" ).getAsInt () != 0 ) {
216
+ throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
217
+ }
218
+ return WxMaAssistantResult .fromJson (responseContent ).getList ();
219
+ }
220
+
221
+
167
222
}
0 commit comments