Просмотр исходного кода

chore: 修改id的类型为Long,修正分页数据库操作

191250028 3 лет назад
Родитель
Сommit
13c1af5e48

+ 3 - 1
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/repository/CommunicationRepository.java

@@ -4,13 +4,15 @@ import cn.seecoder.seecoderportalserver.domain.Communication;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
 
 /**
  * @author fanyanpeng
  * @date 2023/7/12 11:47
  */
+
 public interface CommunicationRepository extends JpaRepository<Communication,Long> {
 
 
-    Page<Communication> findByPublisherId(Pageable pageable);
+    Page<Communication> findByPublisherId(Long publisherId,Pageable pageable);
 }

+ 6 - 6
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/CommunicationService.java

@@ -17,17 +17,17 @@ public interface CommunicationService {
 
     CommunicationVO postCommunication(CommunicationVO communicationVO);
 
-    CommunicationVO getCommunicationDetail(Integer communicationId);
+    CommunicationVO getCommunicationDetail(Long communicationId);
 
-    PageVO<CommunicationVO> getCommunicationPageByUserId(String userId, Integer page, Integer size);
+    PageVO<CommunicationVO> getCommunicationPageByUserId(Long userId, Integer page, Integer size);
 
     PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort);
 
-    Boolean starCommunication(Integer communicationId, Integer userId);
+    Boolean starCommunication(Long communicationId, Long userId);
 
-    Boolean cancelStarCommunication(Integer communicationId, Integer userId);
+    Boolean cancelStarCommunication(Long communicationId, Long userId);
 
-    PageVO<CommunicationVO> getStarredCommunicationPage(Integer userId, Integer page, Integer size);
+    PageVO<CommunicationVO> getStarredCommunicationPage(Long userId, Integer page, Integer size);
 
-    List<UserVO> starredUsers(Integer communicationId);
+    List<UserVO> starredUsers(Long communicationId);
 }

+ 7 - 8
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/serviceImpl/CommunicationServiceImpl.java

@@ -48,9 +48,9 @@ public class CommunicationServiceImpl implements CommunicationService {
 
 
     @Override
-    public PageVO<CommunicationVO> getCommunicationPageByUserId(String userId, Integer page, Integer size) {
+    public PageVO<CommunicationVO> getCommunicationPageByUserId(Long userId, Integer page, Integer size) {
         Pageable pageable = PageRequest.of(page,size);
-        Page<Communication> communicationPage = communicationRepository.findByPublisherId(pageable);
+        Page<Communication> communicationPage = communicationRepository.findByPublisherId(userId,pageable);
         return toPageVO(communicationPage);
     }
 
@@ -96,33 +96,32 @@ public class CommunicationServiceImpl implements CommunicationService {
     }
 
     @Override
-    public CommunicationVO getCommunicationDetail(Integer communicationId) {
+    public CommunicationVO getCommunicationDetail(Long communicationId) {
         return null;
     }
 
-
     @Override
     public PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort) {
         return null;
     }
 
     @Override
-    public Boolean starCommunication(Integer communicationId, Integer userId) {
+    public Boolean starCommunication(Long communicationId, Long userId) {
         return null;
     }
 
     @Override
-    public Boolean cancelStarCommunication(Integer communicationId, Integer userId) {
+    public Boolean cancelStarCommunication(Long communicationId, Long userId) {
         return null;
     }
 
     @Override
-    public PageVO<CommunicationVO> getStarredCommunicationPage(Integer userId, Integer page, Integer size) {
+    public PageVO<CommunicationVO> getStarredCommunicationPage(Long userId, Integer page, Integer size) {
         return null;
     }
 
     @Override
-    public List<UserVO> starredUsers(Integer communicationId) {
+    public List<UserVO> starredUsers(Long communicationId) {
         return null;
     }
 

+ 8 - 8
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/CommunicationController.java

@@ -37,13 +37,13 @@ public class CommunicationController {
 
     @ApiOperation("获得单个交流详情")
     @GetMapping("/{communicationId}")
-    public OkResponse<CommunicationVO> getCommunicationDetail(@PathVariable(value = "communicationId")Integer communicationId){
+    public OkResponse<CommunicationVO> getCommunicationDetail(@PathVariable(value = "communicationId")Long communicationId){
         return OkResponse.of(communicationService.getCommunicationDetail(communicationId));
     }
 
     @ApiOperation("分页获取用户发布的交流")
     @GetMapping("/users/{userId}")
-    public OkResponse<PageVO<CommunicationVO>> getCommunicationPageByUserId(@PathVariable(value = "userId")String userId,
+    public OkResponse<PageVO<CommunicationVO>> getCommunicationPageByUserId(@PathVariable(value = "userId")Long userId,
                                                                            @RequestParam(value = "page") Integer page,
                                                                            @RequestParam(value = "size")Integer size){
         return OkResponse.of(communicationService.getCommunicationPageByUserId(userId,page,size));
@@ -60,21 +60,21 @@ public class CommunicationController {
 
     @ApiOperation("用户收藏交流")
     @PostMapping("/{communicationId}/stars")
-    public OkResponse<Boolean> starCommunication(@PathVariable(value = "communicationId")Integer communicationId,
-                                                 @RequestParam(value = "userId")Integer userId){
+    public OkResponse<Boolean> starCommunication(@PathVariable(value = "communicationId")Long communicationId,
+                                                 @RequestParam(value = "userId")Long userId){
         return OkResponse.of(communicationService.starCommunication(communicationId,userId));
     }
 
     @ApiOperation("取消收藏交流")
     @DeleteMapping("/{communicationId}/stars")
-    public OkResponse<Boolean> cancelStarCommunication(@PathVariable(value = "communicationId")Integer communicationId,
-                                                       @RequestParam(value = "userId")Integer userId){
+    public OkResponse<Boolean> cancelStarCommunication(@PathVariable(value = "communicationId")Long communicationId,
+                                                       @RequestParam(value = "userId")Long userId){
         return OkResponse.of(communicationService.cancelStarCommunication(communicationId,userId));
     }
 
     @ApiOperation("分页查看个人收藏夹")
     @GetMapping("/stars/users/{userId}")
-    public OkResponse<PageVO<CommunicationVO>> getStarredCommunicationPage(@PathVariable(value = "userId") Integer userId,
+    public OkResponse<PageVO<CommunicationVO>> getStarredCommunicationPage(@PathVariable(value = "userId") Long userId,
                                                                            @RequestParam(value = "page")Integer page,
                                                                            @RequestParam(value = "size")Integer size){
         return OkResponse.of(communicationService.getStarredCommunicationPage(userId,page,size));
@@ -83,7 +83,7 @@ public class CommunicationController {
 
     @ApiOperation("查看交流的收藏者")
     @GetMapping("/{communicationId}/stars/users")
-    public OkResponse<List<UserVO>> starredUsers(@PathVariable(value = "communicationId")Integer communicationId){
+    public OkResponse<List<UserVO>> starredUsers(@PathVariable(value = "communicationId")Long communicationId){
         return OkResponse.of(communicationService.starredUsers(communicationId));
     }
 }