From eb5daad9de6c8f177e6bbe0556fae700cabf2b5f Mon Sep 17 00:00:00 2001 From: userName Date: Tue, 30 Dec 2025 17:57:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=98=E6=B1=A0=EF=BC=8C=E5=92=8C=E8=AE=B8?= =?UTF-8?q?=E6=84=BF=E6=A0=91=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CategoryManagementActivity.java | 17 +-- .../livestreaming/GroupDetailActivity.java | 14 +- .../livestreaming/RoomDetailActivity.java | 1 + .../example/livestreaming/SearchActivity.java | 28 ++-- .../example/livestreaming/net/ApiService.java | 122 ++++++++++++++++++ 5 files changed, 152 insertions(+), 30 deletions(-) diff --git a/android-app/app/src/main/java/com/example/livestreaming/CategoryManagementActivity.java b/android-app/app/src/main/java/com/example/livestreaming/CategoryManagementActivity.java index bb436a3a..7c677cd7 100644 --- a/android-app/app/src/main/java/com/example/livestreaming/CategoryManagementActivity.java +++ b/android-app/app/src/main/java/com/example/livestreaming/CategoryManagementActivity.java @@ -181,26 +181,23 @@ public class CategoryManagementActivity extends AppCompatActivity { private void loadCategoryStatistics() { // 获取直播间分类统计(type=8) ApiClient.getService(this).getCategoryStatistics(8) - .enqueue(new Callback>>>() { + .enqueue(new Callback>>() { @Override - public void onResponse(Call>>> call, - Response>>> response) { - ApiResponse>> body = response.body(); - List> statistics = + public void onResponse(Call>> call, + Response>> response) { + ApiResponse> body = response.body(); + Map statistics = response.isSuccessful() && body != null && body.isOk() && body.getData() != null ? body.getData() : null; if (statistics != null && !statistics.isEmpty()) { - Log.d(TAG, "获取到 " + statistics.size() + " 个分类统计"); - for (Map stat : statistics) { - Log.d(TAG, "统计: " + stat.toString()); - } + Log.d(TAG, "获取到分类统计: " + statistics.toString()); } } @Override - public void onFailure(Call>>> call, Throwable t) { + public void onFailure(Call>> call, Throwable t) { Log.e(TAG, "获取分类统计失败: " + t.getMessage(), t); } }); diff --git a/android-app/app/src/main/java/com/example/livestreaming/GroupDetailActivity.java b/android-app/app/src/main/java/com/example/livestreaming/GroupDetailActivity.java index 4489fa89..6ec58132 100644 --- a/android-app/app/src/main/java/com/example/livestreaming/GroupDetailActivity.java +++ b/android-app/app/src/main/java/com/example/livestreaming/GroupDetailActivity.java @@ -95,7 +95,12 @@ public class GroupDetailActivity extends AppCompatActivity { membersAdapter = new GroupMembersAdapter(item -> { if (item == null) return; // 点击成员查看资料 - UserProfileReadOnlyActivity.start(this, item.getUserId()); + UserProfileReadOnlyActivity.start(this, + String.valueOf(item.getUserId()), + item.getNickname(), + "", + "", + 0); }); membersAdapter.setOnMemberLongClickListener(item -> { if (item == null) return; @@ -277,7 +282,12 @@ public class GroupDetailActivity extends AppCompatActivity { .setTitle(member.getNickname()) .setItems(options, (dialog, which) -> { if (which == 0) { - UserProfileReadOnlyActivity.start(this, member.getUserId()); + UserProfileReadOnlyActivity.start(this, + String.valueOf(member.getUserId()), + member.getNickname(), + "", + "", + 0); } else if (which == 1) { showRemoveMemberDialog(member); } diff --git a/android-app/app/src/main/java/com/example/livestreaming/RoomDetailActivity.java b/android-app/app/src/main/java/com/example/livestreaming/RoomDetailActivity.java index df69e011..bb79297a 100644 --- a/android-app/app/src/main/java/com/example/livestreaming/RoomDetailActivity.java +++ b/android-app/app/src/main/java/com/example/livestreaming/RoomDetailActivity.java @@ -29,6 +29,7 @@ import com.example.livestreaming.net.ApiClient; import com.example.livestreaming.net.ApiResponse; import com.example.livestreaming.net.ApiService; import com.example.livestreaming.net.AuthStore; +import com.example.livestreaming.net.ChatMessageResponse; import com.example.livestreaming.net.CreateRechargeRequest; import com.example.livestreaming.net.CreateRechargeResponse; import com.example.livestreaming.net.GiftResponse; diff --git a/android-app/app/src/main/java/com/example/livestreaming/SearchActivity.java b/android-app/app/src/main/java/com/example/livestreaming/SearchActivity.java index a3683950..43ef6345 100644 --- a/android-app/app/src/main/java/com/example/livestreaming/SearchActivity.java +++ b/android-app/app/src/main/java/com/example/livestreaming/SearchActivity.java @@ -152,37 +152,29 @@ public class SearchActivity extends AppCompatActivity { Log.d(TAG, "执行搜索: " + keyword); ApiService apiService = ApiClient.getService(this); - Call>>> call = + Call>> call = apiService.searchLiveRooms(keyword, null, null, 1, 20); - call.enqueue(new Callback>>>() { + call.enqueue(new Callback>>() { @Override - public void onResponse(Call>>> call, - Response>>> response) { + public void onResponse(Call>> call, + Response>> response) { isSearching = false; if (response.isSuccessful() && response.body() != null) { - ApiResponse>> apiResponse = response.body(); + ApiResponse> apiResponse = response.body(); if (apiResponse.getCode() == 200 && apiResponse.getData() != null) { - PageResponse> pageResponse = apiResponse.getData(); - List> rooms = pageResponse.getList(); + PageResponse pageResponse = apiResponse.getData(); + List rooms = pageResponse.getList(); if (rooms != null && !rooms.isEmpty()) { - List roomList = new ArrayList<>(); - for (Map roomData : rooms) { - Room room = parseRoomFromMap(roomData); - if (room != null) { - roomList.add(room); - } - } - all.clear(); - all.addAll(roomList); + all.addAll(rooms); adapter.submitList(new ArrayList<>(all)); updateEmptyState(all); - Log.d(TAG, "搜索成功,找到 " + roomList.size() + " 个直播间"); + Log.d(TAG, "搜索成功,找到 " + rooms.size() + " 个直播间"); } else { all.clear(); adapter.submitList(new ArrayList<>()); @@ -204,7 +196,7 @@ public class SearchActivity extends AppCompatActivity { } @Override - public void onFailure(Call>>> call, Throwable t) { + public void onFailure(Call>> call, Throwable t) { isSearching = false; Toast.makeText(SearchActivity.this, "网络错误: " + t.getMessage(), diff --git a/android-app/app/src/main/java/com/example/livestreaming/net/ApiService.java b/android-app/app/src/main/java/com/example/livestreaming/net/ApiService.java index ee1e1b82..840383ac 100644 --- a/android-app/app/src/main/java/com/example/livestreaming/net/ApiService.java +++ b/android-app/app/src/main/java/com/example/livestreaming/net/ApiService.java @@ -265,4 +265,126 @@ public interface ApiService { Call> transferGroup( @Path("groupId") long groupId, @Body TransferGroupRequest body); + + // ==================== 分类接口 ==================== + + @GET("api/front/category/live") + Call>> getLiveRoomCategories(); + + @GET("api/front/category/work") + Call>> getWorkCategories(); + + @GET("api/front/category/list") + Call>> getCategories(@Query("type") int type); + + @GET("api/front/category/hot") + Call>> getHotCategories( + @Query("type") int type, + @Query("limit") int limit); + + @GET("api/front/category/statistics") + Call>> getCategoryStatistics(@Query("type") int type); + + // ==================== 关注接口 ==================== + + @GET("api/front/follow/followers") + Call>>> getFollowersList( + @Query("page") int page, + @Query("pageSize") int pageSize); + + @GET("api/front/follow/following") + Call>>> getFollowingList( + @Query("page") int page, + @Query("pageSize") int pageSize); + + @GET("api/front/follow/stats") + Call>> getFollowStats(@Query("userId") Integer userId); + + @GET("api/front/follow/check/{userId}") + Call>> checkFollowStatus(@Path("userId") int userId); + + @POST("api/front/follow") + Call>> followUser(@Body Map body); + + @POST("api/front/follow/cancel") + Call>> unfollowUser(@Body Map body); + + // ==================== 作品接口 ==================== + + @Multipart + @POST("api/front/upload/video") + Call> uploadVideo( + @Part MultipartBody.Part file, + @Part("model") RequestBody model, + @Part("pid") RequestBody pid); + + @POST("api/front/works/publish") + Call> publishWork(@Body WorksRequest body); + + @GET("api/front/works/{id}") + Call> getWorkDetail(@Path("id") long id); + + @DELETE("api/front/works/{id}") + Call> deleteWork(@Path("id") long id); + + @POST("api/front/works/{id}/like") + Call> likeWork(@Path("id") long id); + + @DELETE("api/front/works/{id}/like") + Call> unlikeWork(@Path("id") long id); + + @POST("api/front/works/{id}/collect") + Call> collectWork(@Path("id") long id); + + @DELETE("api/front/works/{id}/collect") + Call> uncollectWork(@Path("id") long id); + + // ==================== 搜索接口 ==================== + + @GET("api/front/live/public/rooms/search") + Call>> searchLiveRooms( + @Query("keyword") String keyword, + @Query("categoryId") Integer categoryId, + @Query("status") Integer status, + @Query("page") int page, + @Query("pageSize") int pageSize); + + @GET("api/front/search/hot") + Call>> getHotSearch( + @Query("type") int type, + @Query("limit") int limit); + + @GET("api/front/search/suggestions") + Call>> getSearchSuggestions( + @Query("keyword") String keyword, + @Query("type") int type, + @Query("limit") int limit); + + // ==================== 观看历史 ==================== + + @POST("api/front/history/watch") + Call>> recordWatchHistory(@Body Map body); + + // ==================== 支付接口 ==================== + + @POST("api/front/pay/payment") + Call> payment(@Body OrderPayRequest body); + + // ==================== 直播间礼物 ==================== + + @POST("api/front/live/rooms/{roomId}/gift") + Call> sendRoomGift( + @Path("roomId") String roomId, + @Body SendGiftRequest body); + + // ==================== 直播控制 ==================== + + @POST("api/front/live/rooms/{roomId}/start") + Call>> startLiveRoom(@Path("roomId") String roomId); + + @POST("api/front/live/rooms/{roomId}/stop") + Call>> stopLiveRoom(@Path("roomId") String roomId); + + @POST("api/front/live/rooms/{roomId}/broadcast/online") + Call>> broadcastOnlineCount(@Path("roomId") String roomId); }