فهرست منبع

众测大赛more

git 5 سال پیش
والد
کامیت
831e04e5ba

+ 1 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/CompetitionDao.java

@@ -17,6 +17,7 @@ public interface CompetitionDao extends CrudRepository<CompetitionPO, Long>{
 
     List<CompetitionPO> findAll(Pageable pageable);
 
+
 //    @Query(value = "SELECT new com.mooctest.crowd.domain.domainobject.Competition(c.id,c.name,c.linkUrl,c.startTime,c.isDeleted) FROM CompetitionPO c where c.isDeleted=0 ORDER BY c.startTime DESC")
 //    List<Competition> findTop3(Pageable pageable);
 }

+ 18 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/CompetitionsDao.java

@@ -0,0 +1,18 @@
+package com.mooctest.crowd.domain.dao;
+
+import com.mooctest.crowd.domain.model.CompetitionPO;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import javax.transaction.Transactional;
+
+@Transactional
+public interface CompetitionsDao extends CrudRepository<CompetitionPO, Long>,PagingAndSortingRepository<CompetitionPO, Long>, JpaRepository<CompetitionPO, Long>,JpaSpecificationExecutor<CompetitionPO> {
+
+    Page<CompetitionPO> findAll(Specification<CompetitionPO> spec , Pageable pageable);
+}

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/TechnicalArticlesDao.java

@@ -28,4 +28,4 @@ public interface TechnicalArticlesDao extends PagingAndSortingRepository<Technic
     @Modifying
     @Query(nativeQuery = true,value="update  technical_articles set TA_READING=TA_READING+1 where TA_ID=?")
     int updateReading(@Param("id") long id);
-}
+}

+ 7 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/CommonRepo.java

@@ -56,6 +56,9 @@ public class CommonRepo {
     @Autowired
     private ExpertDao expertDao;
 
+    @Autowired
+    private  CompetitionsDao competitionsDao;
+
     public List<TestType> getAllTestType(){
         return testTypeDao.findAll().stream().map(testTypePO -> Converter.convert(TestType.class, testTypePO)).collect(Collectors.toList());
     }
@@ -78,6 +81,10 @@ public class CommonRepo {
                 .filter(competition -> competition.getIsDeleted() == DeletedStatus.isNotDeleted).collect(Collectors.toList());
     }
 
+    public Page<Competition> findAllCompetition(Pageable pageable) {
+        return  competitionsDao.findAll(pageable).map(CompetitionPO -> Converter.convert(Competition.class, CompetitionPO));
+    }
+
     public List<Competition> getAllCompetitionTop3(Pageable pageable){
         List<CompetitionPO> competitionPOS = competitionDao.findAll(pageable);
         return competitionPOS.stream().map(competitionPO -> Converter.convert(Competition.class, competitionPO))

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java


+ 2 - 4
site/src/main/java/com/mooctest/crowd/site/data/dto/IndexPageDTO.java

@@ -1,9 +1,6 @@
 package com.mooctest.crowd.site.data.dto;
 
-import com.mooctest.crowd.site.data.vo.AgencyVO;
-import com.mooctest.crowd.site.data.vo.CrowdProjectVO;
-import com.mooctest.crowd.site.data.vo.ExpertVO;
-import com.mooctest.crowd.site.data.vo.ResourceVO;
+import com.mooctest.crowd.site.data.vo.*;
 import lombok.Data;
 import org.springframework.data.domain.Page;
 
@@ -13,4 +10,5 @@ public class IndexPageDTO {
     Page<AgencyVO> agencyPage;
     Page<ResourceVO> resourcePage;
     Page<ExpertVO> expertPage;
+    Page<CompetitionVO> competitionPage;
 }

+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java

@@ -88,4 +88,6 @@ public interface ViewMediator {
     BankCardDTO deleteBankCard(long id,long userId);
 
     TechnicalArticlesDTO  updateRanking(long id);
+
+    IndexInfoDTO getHotTesting();
 }

+ 24 - 2
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -29,7 +29,6 @@ import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.awt.*;
 import java.io.File;
@@ -790,7 +789,6 @@ public class WebMediatorImpl implements ViewMediator {
             userVO.setProvince(userPO.get().getProvince());
             userVO.setCity(userPO.get().getCity());
             userVO.setCounty(userPO.get().getCounty());
-            userVO.setDetailedAddress(userPO.get().getDetailedAddress());
             userVO.setPersonalCompetence(userPO.get().getPersonalCompetence());
             userDTO.setUserVO(userVO);
             return userDTO;
@@ -923,6 +921,30 @@ public class WebMediatorImpl implements ViewMediator {
         return technicalArticlesDTO;
     }
 
+    @Override
+    public IndexInfoDTO getHotTesting() {
+        IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
+        Pageable pageable = PageRequest.of(0, 10);
+        int top = 10;
+        //获取热门众测
+        List<ApplicationTypeVO> applicationTypeRank = projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
+            ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
+            ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
+            applicationTypeVO.setCount(rankInfos.getCount());
+            return applicationTypeVO;
+        }).filter(Objects::nonNull).collect(Collectors.toList());
+        List<ApplicationTypeVO> applicationTypeRanks = new ArrayList<>();
+        if (applicationTypeRanks.size() > top) {
+            for (int i = 0; i < top; i++) {
+                applicationTypeRanks.add(applicationTypeRank.get(i));
+            }
+        } else {
+            applicationTypeRanks = applicationTypeRank;
+        }
+        indexInfoDTO.setApplicationTypeRank(applicationTypeRanks);
+        return  indexInfoDTO;
+    }
+
     private ProjectOperationControl initProjectPermission(CrowdTestProject project, User user) {
         ProjectOperationControl operationControl = new ProjectOperationControl();
         if (user == null)

+ 4 - 0
site/src/main/java/com/mooctest/crowd/site/service/CommonService.java

@@ -25,4 +25,8 @@ public interface CommonService {
     Page<CrowdProjectVO> getProjectInfo(Pageable pageable, String keyword, int deletedStatus);
 
     Page<CrowdTaskVO> getTaskinfo(Pageable pageable, String keyword, int deletedStatus);
+
+    IndexInfoDTO getHotTesting();
+
+    IndexPageDTO getCompetition(Pageable pageable);
 }

+ 13 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/CommonServiceImpl.java

@@ -86,4 +86,17 @@ public class CommonServiceImpl implements CommonService {
         return   taskRepo.findAllByPage(pageable,keyword,deletedStatus).map(crowdTestTask -> new CrowdTaskVO(crowdTestTask));
     }
 
+    @Override
+    public IndexInfoDTO getHotTesting() {
+        IndexInfoDTO indexInfoDTO = viewMediator.getHotTesting();
+        return indexInfoDTO;
+    }
+
+    @Override
+    public IndexPageDTO getCompetition(Pageable pageable) {
+        IndexPageDTO indexPageDTO = new IndexPageDTO();
+        indexPageDTO.setCompetitionPage(commonRepo.findAllCompetition(pageable).map(competition -> new CompetitionVO(competition)));
+        return indexPageDTO;
+    }
+
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است