Przeglądaj źródła

feat:完成了一些交流的功能

DingXiaoYu 3 lat temu
rodzic
commit
9a925c19e2

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

@@ -4,7 +4,6 @@ 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

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

@@ -22,7 +22,7 @@ public interface CommunicationService {
 
     PageVO<CommunicationVO> getCommunicationPageByUserId(Long userId, Integer page, Integer size);
 
-    PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort);
+    PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort, Long userId);
 
     Boolean starCommunication(Long communicationId, Long userId);
 

+ 12 - 2
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/serviceImpl/CommunicationServiceImpl.java

@@ -15,6 +15,7 @@ import cn.seecoder.seecoderportalserver.web.rest.errors.CustomErrorException;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
@@ -144,8 +145,17 @@ public class CommunicationServiceImpl implements CommunicationService {
 
 
     @Override
-    public PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort) {
-        return null;
+    public PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort, Long userId) {
+        List<Sort.Order> orders=new ArrayList<>();
+        if (sort==CommunicationSortStrategyEnum.PUBLISH_TIME_ASC){
+            orders.add(new Sort.Order(Sort.Direction.ASC,"publish_time"));
+        }else {
+            orders.add(new Sort.Order(Sort.Direction.DESC,"publish_time"));
+        }
+        orders.add(new Sort.Order(Sort.Direction.DESC,"deadline"));
+        Pageable pageable = PageRequest.of(page,size,Sort.by(orders));
+        Page<Communication> communicationPage = communicationRepository.findAll(pageable);
+        return toPageVO(communicationPage,userId);
     }
 
     @Override

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

@@ -63,7 +63,9 @@ public class CommunicationController {
     public OkResponse<PageVO<CommunicationVO>> getCommunicationPage(@RequestParam(value = "page") Integer page,
                                                                   @RequestParam(value = "size")Integer size,
                                                                   @RequestParam(value = "sort") CommunicationSortStrategyEnum sort){
-        return OkResponse.of(communicationService.getCommunicationPage(page,size,sort));
+        DomainUserDetails user = SecurityUtils.getCurrentUser();
+        Long userId = user.getId();
+        return OkResponse.of(communicationService.getCommunicationPage(page,size,sort,userId));
     }