user module API & resource module API
GET /user/thread
POST /resource/version
GET /resource/search
GET /resource/info
GET /resource/hot
GET /resource/hot/slide
GET /resource/hot-trend
PUT /resource/info
Change-Id: I39c94b06a1d69967b8e235a67a0133c8095abb38
diff --git a/src/main/java/com/g9/g9backend/controller/UserController.java b/src/main/java/com/g9/g9backend/controller/UserController.java
index 9315e8e..7daf5f3 100644
--- a/src/main/java/com/g9/g9backend/controller/UserController.java
+++ b/src/main/java/com/g9/g9backend/controller/UserController.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.g9.g9backend.pojo.*;
import com.g9.g9backend.pojo.DTO.*;
+import com.g9.g9backend.pojo.Thread;
import com.g9.g9backend.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +44,9 @@
private final ResourceService resourceService;
- public UserController(UserService userService, InvitationService invitationService, SubscriptionService subscriptionService, SearchHistoryService searchHistoryService, RewardService rewardService, UserCollectionService userCollectionService, UserUploadService userUploadService, UserPurchaseService userPurchaseService, ResourceService resourceService) {
+ private final ThreadService threadService;
+
+ public UserController(UserService userService, InvitationService invitationService, SubscriptionService subscriptionService, SearchHistoryService searchHistoryService, RewardService rewardService, UserCollectionService userCollectionService, UserUploadService userUploadService, UserPurchaseService userPurchaseService, ResourceService resourceService, ThreadService threadService) {
this.userService = userService;
this.invitationService = invitationService;
this.subscriptionService = subscriptionService;
@@ -53,6 +56,7 @@
this.userUploadService = userUploadService;
this.userPurchaseService = userPurchaseService;
this.resourceService = resourceService;
+ this.threadService = threadService;
}
@@ -397,6 +401,30 @@
}
/**
+ * 获取用户发布贴子
+ *
+ * @param userId 用户id
+ * @param pageNumber 页数
+ * @param rows 行数
+ * @return 获取用户发布贴子结果
+ */
+ @GetMapping("/thread")
+ public ResponseEntity<GetUserThreadListDTO> getUserThread(@RequestParam int userId, @RequestParam int pageNumber, @RequestParam int rows) {
+ IPage<Thread> page = new Page<>(pageNumber, rows);
+ QueryWrapper<Thread> threadQuery = new QueryWrapper<>();
+ threadQuery.eq("user_id", userId);
+ IPage<Thread> threadPage = threadService.page(page, threadQuery);
+ List<Thread> threadList = threadPage.getRecords();
+ long total = threadPage.getTotal();
+ long pages = threadPage.getPages();
+ long current = threadPage.getCurrent();
+ long size = threadPage.getSize();
+
+ GetUserThreadListDTO getUserThreadListDTO = new GetUserThreadListDTO(threadList, total, pages, current, size);
+ return ResponseEntity.ok(getUserThreadListDTO);
+ }
+
+ /**
* 获取用户数据
*
* @param userId 用户id