Skip to content

Commit 2afc86a

Browse files
committed
feat: remove param check on sdk level
1 parent e1be13a commit 2afc86a

File tree

13 files changed

+43
-733
lines changed

13 files changed

+43
-733
lines changed

src/main/java/com/netease/nim/server/sdk/im/v1/history/HistoryV1Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public Result<QueryUserEventsResponseV1> queryUserEvents(QueryUserEventsRequestV
291291
if (events != null) {
292292
for (Object evt : events) {
293293
// evt 可能是 JSONObject,需要转成 UserEvent
294-
QueryUserEventsResponseV1.UserEvent userEvent = JSON.toJavaObject((JSONObject) evt, QueryUserEventsResponseV1.UserEvent.class);
294+
QueryUserEventsResponseV1.UserEvent userEvent = JSON.toJavaObject(evt, QueryUserEventsResponseV1.UserEvent.class);
295295
userEvents.add(userEvent);
296296
}
297297
}

src/main/java/com/netease/nim/server/sdk/im/v2/ai/AiService.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.netease.nim.server.sdk.core.http.HttpMethod;
99
import com.netease.nim.server.sdk.im.v2.ai.request.ChatAssistRequestV2;
1010
import com.netease.nim.server.sdk.im.v2.ai.response.ChatAssistResponseV2;
11-
import com.netease.nim.server.sdk.im.v2.tool.ToolV2UrlContext;
1211
import com.netease.nim.server.sdk.im.v2.util.ResultUtils;
1312

1413
public class AiService implements IAiSerivce{
@@ -20,17 +19,8 @@ public AiService(YunxinApiHttpClient yunxinApiHttpClient) {
2019

2120
@Override
2221
public Result<ChatAssistResponseV2> chatAssist(ChatAssistRequestV2 request) throws YunxinSdkException {
23-
if (request.getSenderId() == null) {
24-
throw new IllegalArgumentException("sender_id is required");
25-
}
26-
if (request.getReceiverId() == null) {
27-
throw new IllegalArgumentException("receiver_id is required");
28-
}
29-
if (request.getStyleList() == null || request.getStyleList().isEmpty()) {
30-
throw new IllegalArgumentException("style_list is required");
31-
}
3222
String body = JSON.toJSONString(request);
33-
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(HttpMethod.POST, AiUrlContext.CHAT_ASSIST_URL,AiUrlContext.CHAT_ASSIST_URL,null,body );
23+
YunxinApiResponse apiResponse = yunxinApiHttpClient.executeV2Api(HttpMethod.POST, AiUrlContext.CHAT_ASSIST_URL, AiUrlContext.CHAT_ASSIST_URL,null, body);
3424
return ResultUtils.convert(apiResponse,ChatAssistResponseV2.class);
3525
}
3626
}

src/main/java/com/netease/nim/server/sdk/im/v2/broadcast/BroadcastV2Service.java

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ public BroadcastV2Service(YunxinApiHttpClient yunxinApiHttpClient) {
3838
}
3939

4040
@Override
41-
public Result<SendBroadcastNotificationResponseV2> sendBroadcastNotification(
42-
SendBroadcastNotificationRequestV2 request) throws YunxinSdkException {
43-
44-
// Validate required parameters
45-
if (request.getContent() == null || request.getContent().isEmpty()) {
46-
throw new IllegalArgumentException("Content cannot be null or empty");
47-
}
41+
public Result<SendBroadcastNotificationResponseV2> sendBroadcastNotification(SendBroadcastNotificationRequestV2 request) throws YunxinSdkException {
4842

4943
// Convert to JSON string using JSONField annotations
5044
String jsonRequestBody = JSON.toJSONString(request);
@@ -60,14 +54,8 @@ public Result<SendBroadcastNotificationResponseV2> sendBroadcastNotification(
6054
}
6155

6256
@Override
63-
public Result<DeleteBroadcastNotificationResponseV2> deleteBroadcastNotification(
64-
DeleteBroadcastNotificationRequestV2 request) throws YunxinSdkException {
65-
66-
// Validate required parameters
67-
if (request.getBroadcastId() == null || request.getBroadcastId().isEmpty()) {
68-
throw new IllegalArgumentException("Broadcast ID cannot be null or empty");
69-
}
70-
57+
public Result<DeleteBroadcastNotificationResponseV2> deleteBroadcastNotification(DeleteBroadcastNotificationRequestV2 request) throws YunxinSdkException {
58+
7159
// Replace the path parameter in the URL
7260
String path = BroadcastV2UrlContext.DELETE_BROADCAST_NOTIFICATION
7361
.replace("{broadcast_id}", request.getBroadcastId());
@@ -85,13 +73,7 @@ public Result<DeleteBroadcastNotificationResponseV2> deleteBroadcastNotification
8573
}
8674

8775
@Override
88-
public Result<QueryBroadcastNotificationResponseV2> queryBroadcastNotification(
89-
QueryBroadcastNotificationRequestV2 request) throws YunxinSdkException {
90-
91-
// Validate required parameters
92-
if (request.getBroadcastId() == null || request.getBroadcastId().isEmpty()) {
93-
throw new IllegalArgumentException("Broadcast ID cannot be null or empty");
94-
}
76+
public Result<QueryBroadcastNotificationResponseV2> queryBroadcastNotification(QueryBroadcastNotificationRequestV2 request) throws YunxinSdkException {
9577

9678
// Replace the path parameter in the URL
9779
String path = BroadcastV2UrlContext.QUERY_BROADCAST_NOTIFICATION
@@ -141,21 +123,7 @@ public Result<QueryBroadcastNotificationListResponseV2> queryBroadcastNotificati
141123
}
142124

143125
@Override
144-
public Result<SendChatroomBroadcastNotificationResponseV2> sendChatroomBroadcastNotification(
145-
SendChatroomBroadcastNotificationRequestV2 request) throws YunxinSdkException {
146-
147-
// Validate required parameters
148-
if (request.getClientBroadcastId() == null || request.getClientBroadcastId().isEmpty()) {
149-
throw new IllegalArgumentException("Client broadcast ID cannot be null or empty");
150-
}
151-
152-
if (request.getSenderId() == null || request.getSenderId().isEmpty()) {
153-
throw new IllegalArgumentException("Sender ID cannot be null or empty");
154-
}
155-
156-
if (request.getMessage() == null) {
157-
throw new IllegalArgumentException("Message cannot be null");
158-
}
126+
public Result<SendChatroomBroadcastNotificationResponseV2> sendChatroomBroadcastNotification(SendChatroomBroadcastNotificationRequestV2 request) throws YunxinSdkException {
159127

160128
// Convert to JSON string using JSONField annotations
161129
String jsonRequestBody = JSON.toJSONString(request);

src/main/java/com/netease/nim/server/sdk/im/v2/chatroom/ChatroomV2Service.java

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ public ChatroomV2Service(YunxinApiHttpClient httpClient) {
4141

4242
@Override
4343
public Result<CreateChatroomResponseV2> createChatroom(CreateChatroomRequestV2 request) throws YunxinSdkException {
44-
// Validate required parameters
45-
if (request.getCreator() == null || request.getCreator().isEmpty()) {
46-
throw new IllegalArgumentException("Creator cannot be null or empty");
47-
}
48-
49-
if (request.getRoomName() == null || request.getRoomName().isEmpty()) {
50-
throw new IllegalArgumentException("Room name cannot be null or empty");
51-
}
52-
44+
5345
// Convert the request to JSON string
5446
String requestBody = JSONObject.toJSONString(request);
5547

@@ -67,20 +59,7 @@ public Result<CreateChatroomResponseV2> createChatroom(CreateChatroomRequestV2 r
6759

6860
@Override
6961
public Result<GetChatroomAddressResponseV2> getChatroomAddress(GetChatroomAddressRequestV2 request) throws YunxinSdkException {
70-
// Validate required parameters
71-
if (request.getRoomId() == null) {
72-
throw new IllegalArgumentException("Chatroom ID cannot be null");
73-
}
74-
75-
if (request.getAccountId() == null || request.getAccountId().isEmpty()) {
76-
throw new IllegalArgumentException("Account ID cannot be null or empty");
77-
}
78-
79-
if (request.getClientIp() == null || request.getClientIp().isEmpty()) {
80-
throw new IllegalArgumentException("Client IP cannot be null or empty");
81-
}
8262

83-
8463
// Replace the path parameter in the URL
8564
String path = ChatroomV2UrlContext.GET_CHATROOM_ADDRESS.replace("{room_id}", request.getRoomId().toString());
8665

@@ -111,11 +90,7 @@ public Result<GetChatroomAddressResponseV2> getChatroomAddress(GetChatroomAddres
11190

11291
@Override
11392
public Result<GetChatroomInfoResponseV2> getChatroomInfo(GetChatroomInfoRequestV2 request) throws YunxinSdkException {
114-
// Validate required parameters
115-
if (request.getRoomId() == null) {
116-
throw new IllegalArgumentException("Chatroom ID cannot be null");
117-
}
118-
93+
11994
// Replace the path parameter in the URL
12095
String path = ChatroomV2UrlContext.GET_CHATROOM_INFO.replace("{room_id}", request.getRoomId().toString());
12196

@@ -144,10 +119,6 @@ public Result<GetChatroomInfoResponseV2> getChatroomInfo(GetChatroomInfoRequestV
144119

145120
@Override
146121
public Result<UpdateChatroomInfoResponseV2> updateChatroomInfo(UpdateChatroomInfoRequestV2 request) throws YunxinSdkException {
147-
// Validate required parameters
148-
if (request.getRoomId() == null) {
149-
throw new IllegalArgumentException("Chatroom ID cannot be null");
150-
}
151122
// Replace the path parameter in the URL
152123
String path = ChatroomV2UrlContext.UPDATE_CHATROOM_INFO.replace("{room_id}", request.getRoomId().toString());
153124

@@ -168,15 +139,6 @@ public Result<UpdateChatroomInfoResponseV2> updateChatroomInfo(UpdateChatroomInf
168139

169140
@Override
170141
public Result<UpdateChatroomStatusResponseV2> updateChatroomStatus(UpdateChatroomStatusRequestV2 request) throws YunxinSdkException {
171-
172-
if (request.getOperatorAccountId() == null || request.getOperatorAccountId().isEmpty()) {
173-
throw new IllegalArgumentException("Operator account ID cannot be null or empty");
174-
}
175-
176-
if (request.getValid() == null) {
177-
throw new IllegalArgumentException("Valid status cannot be null");
178-
}
179-
180142
// Replace the path parameter in the URL
181143
String path = ChatroomV2UrlContext.UPDATE_CHATROOM_STATUS.replace("{room_id}", String.valueOf(request.getRoomId()));
182144

@@ -199,15 +161,6 @@ public Result<UpdateChatroomStatusResponseV2> updateChatroomStatus(UpdateChatroo
199161
@Override
200162
public Result<ToggleChatroomMuteResponseV2> toggleChatroomMute(ToggleChatroomMuteRequestV2 request) throws YunxinSdkException {
201163

202-
if (request.getOperatorAccountId() == null || request.getOperatorAccountId().isEmpty()) {
203-
throw new IllegalArgumentException("Operator account ID cannot be null or empty");
204-
}
205-
206-
if (request.getChatBanned() == null) {
207-
throw new IllegalArgumentException("Chat banned status cannot be null");
208-
}
209-
210-
211164
// Replace the path parameter in the URL
212165
String path = ChatroomV2UrlContext.TOGGLE_CHATROOM_MUTE.replace("{room_id}", String.valueOf(request.getRoomId()));
213166

@@ -228,15 +181,7 @@ public Result<ToggleChatroomMuteResponseV2> toggleChatroomMute(ToggleChatroomMut
228181

229182
@Override
230183
public Result<ToggleInOutNotificationResponseV2> toggleInOutNotification(ToggleInOutNotificationRequestV2 request) throws YunxinSdkException {
231-
// Validate required parameters
232-
if (request.getRoomId() == null) {
233-
throw new IllegalArgumentException("Chatroom ID cannot be null");
234-
}
235-
236-
if (request.getInOutNotification() == null) {
237-
throw new IllegalArgumentException("In/out notification status cannot be null");
238-
}
239-
184+
240185
// Replace the path parameter in the URL
241186
String path = ChatroomV2UrlContext.TOGGLE_IN_OUT_NOTIFICATION.replace("{room_id}", request.getRoomId().toString());
242187

@@ -258,11 +203,7 @@ public Result<ToggleInOutNotificationResponseV2> toggleInOutNotification(ToggleI
258203

259204
@Override
260205
public Result<QueryOpenChatroomsResponseV2> queryOpenChatrooms(QueryOpenChatroomsRequestV2 request) throws YunxinSdkException {
261-
// Validate required parameters
262-
if (request.getCreatorAccountId() == null || request.getCreatorAccountId().isEmpty()) {
263-
throw new IllegalArgumentException("Creator account ID cannot be null or empty");
264-
}
265-
206+
266207
// Set up query parameters
267208
Map<String, String> queryParams = new HashMap<>();
268209
queryParams.put("creator_account_id", request.getCreatorAccountId());
@@ -281,18 +222,6 @@ public Result<QueryOpenChatroomsResponseV2> queryOpenChatrooms(QueryOpenChatroom
281222

282223
@Override
283224
public Result<ListOnlineMembersResponseV2> listOnlineMembers(ListOnlineMembersRequestV2 request) throws YunxinSdkException {
284-
// Validate required parameters
285-
if (request.getRoomId() == null) {
286-
throw new IllegalArgumentException("Chatroom ID cannot be null");
287-
}
288-
289-
if (request.getOffset() == null) {
290-
throw new IllegalArgumentException("Offset cannot be null");
291-
}
292-
293-
if (request.getLimit() == null) {
294-
throw new IllegalArgumentException("Limit cannot be null");
295-
}
296225
// Replace the path parameter in the URL
297226
String path = ChatroomV2UrlContext.LIST_ONLINE_MEMBERS.replace("{room_id}", request.getRoomId().toString());
298227

@@ -319,11 +248,7 @@ public Result<ListOnlineMembersResponseV2> listOnlineMembers(ListOnlineMembersRe
319248

320249
@Override
321250
public Result<ListFixedMembersResponseV2> listFixedMembers(ListFixedMembersRequestV2 request) throws YunxinSdkException {
322-
// Validate required parameters
323-
if (request.getRoomId() == null) {
324-
throw new IllegalArgumentException("Chatroom ID cannot be null");
325-
}
326-
251+
327252
// Replace the path parameter in the URL
328253
String path = ChatroomV2UrlContext.LIST_FIXED_MEMBERS.replace("{room_id}", request.getRoomId().toString());
329254

0 commit comments

Comments
 (0)