瀏覽代碼

Merge branch 'feature-V2.0' of http://git.mooctest.com/crowd-2019/crowd-test-service-backend into feature-V2.0

 Conflicts:
	site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java
xuxuan 5 年之前
父節點
當前提交
13318cc57c

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

@@ -1,18 +1,26 @@
 package com.mooctest.crowd.domain.dao;
 
 import com.mooctest.crowd.domain.model.ApplicationTypePO;
+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;
 import java.util.List;
 import java.util.Optional;
 
 @Transactional
-public interface ApplicationTypeDao extends CrudRepository<ApplicationTypePO, Long>{
+public interface ApplicationTypeDao extends CrudRepository<ApplicationTypePO, Long>,PagingAndSortingRepository<ApplicationTypePO, Long>, JpaRepository<ApplicationTypePO, Long>,JpaSpecificationExecutor<ApplicationTypePO> {
 
     Optional<ApplicationTypePO> findByCode(String code);
 
     Optional<ApplicationTypePO> findById(Long id);
 
     List<ApplicationTypePO> findAll();
+
+    Page<ApplicationTypePO> findAll(Specification<ApplicationTypePO> spec , Pageable pageable);
 }

+ 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);
-}
+}

+ 1 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/ApplicationType.java

@@ -15,4 +15,5 @@ public class ApplicationType {
     private String name;
     private String image;
     private List<TestType> testTypeList;
+    private Long count;
 }

+ 3 - 0
core/src/main/java/com/mooctest/crowd/domain/model/ApplicationTypePO.java

@@ -24,4 +24,7 @@ public class ApplicationTypePO {
 
     @Column(name = "AT_IMAGE")
     private String image;
+
+    @Column(name="AT_COUNT")
+    private Long count;
 }

+ 25 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/ApplicationTypeRepo.java

@@ -0,0 +1,25 @@
+package com.mooctest.crowd.domain.repository;
+
+import com.mooctest.crowd.domain.dao.ApplicationTypeDao;
+import com.mooctest.crowd.domain.domainobject.ApplicationType;
+import com.mooctest.crowd.domain.util.Converter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+public class ApplicationTypeRepo implements IApplicationTypeRepo{
+
+
+    @Autowired
+    private ApplicationTypeDao applicationTypeDao;
+
+    @Override
+    public Page<ApplicationType> getHotTesting(Pageable pageable) {
+        return applicationTypeDao.findAll(pageable).map(ApplicationTypePO->Converter.convert(ApplicationType.class, ApplicationTypePO));
+    }
+}

+ 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))

+ 12 - 0
core/src/main/java/com/mooctest/crowd/domain/repository/IApplicationTypeRepo.java

@@ -0,0 +1,12 @@
+package com.mooctest.crowd.domain.repository;
+
+import com.mooctest.crowd.domain.domainobject.ApplicationType;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+
+public interface IApplicationTypeRepo {
+
+    Page<ApplicationType> getHotTesting(Pageable pageable);
+
+}

文件差異過大導致無法顯示
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java


+ 3 - 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,6 @@ public class IndexPageDTO {
     Page<AgencyVO> agencyPage;
     Page<ResourceVO> resourcePage;
     Page<ExpertVO> expertPage;
+    Page<CompetitionVO> competitionPage;
+    Page<ApplicationTypeVO> applicationTypePage;
 }

+ 1 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/ApplicationTypeVO.java

@@ -26,5 +26,6 @@ public class ApplicationTypeVO implements Serializable {
         code = applicationType.getCode();
         name = applicationType.getName();
         image = applicationType.getImage();
+        count=applicationType.getCount();
     }
 }

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

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

+ 15 - 34
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -108,37 +108,6 @@ public class WebMediatorImpl implements ViewMediator {
     private String agencyId;
 
     @Override
-    public List<EvolutionAgencyVO> agencypoToVO(List<Optional<EvaluationAgencyPO>> optionalList) {
-             List<EvolutionAgencyVO> evolutionAgencyVOS=optionalList.stream().map(evaluationAgencyPO -> {
-                 EvaluationAgency evaluationAgency = new EvaluationAgency();
-                 BeanUtils.copyProperties(evaluationAgencyPO, evaluationAgency);
-                 return new EvolutionAgencyVO(evaluationAgency);
-             }).collect(Collectors.toList());
-
-             return  evolutionAgencyVOS;
-    }
-
-    @Override
-    public List<CrowdTaskVO> findMoreHotTasks() {
-        List<CrowdTaskVO>  moreHotTasks = taskDao.findMoreHotTasks().stream().map(crowdTestTaskPO->{
-            CrowdTestTask task = new CrowdTestTask();
-            BeanUtils.copyProperties(crowdTestTaskPO, task);
-            return new CrowdTaskVO(task);
-        }).collect(Collectors.toList());
-        return moreHotTasks;
-    }
-
-    @Override
-    public List<CrowdTestProjectVO> findMoreHotProjects() {
-        List<CrowdTestProjectVO>  moreHotProjects = projectDao.findAll().stream().map(crowdTestProjectPO->{
-            CrowdTestProject project = new CrowdTestProject();
-            BeanUtils.copyProperties(crowdTestProjectPO, project);
-            return new CrowdTestProjectVO(project);
-        }).collect(Collectors.toList());
-        return moreHotProjects;
-    }
-
-    @Override
     public EnterpriseAuthVO getEnterpriseAuthByUserId(Long userId) {
         EnterpriseAuthentication enterpriseAuthentication = new EnterpriseAuthentication();
         EnterpriseAuthenticationPO enterpriseAuthenticationPO = enterpriseAuthenticationDao.findByUserId(userId);
@@ -204,7 +173,6 @@ public class WebMediatorImpl implements ViewMediator {
                 EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
                 agencyVO.setName(agency.getEvaluationAgencyName());
                 agencyVO.setLogo(agency.getAgencyPhoto());
-
                 agencyVO.setTaskCount(rankInfo.getCount());
                 agencyVO.setId(agency.getId());
                 agencyVO.setUserId(agency.getUserId());
@@ -697,7 +665,7 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public List<EvolutionAgencyVO> renderAgencyList(){
+    public List<EvolutionAgencyVO> renderAgencyList() {
         List<EvolutionAgencyVO> agencyList = new ArrayList<>();
         EvaluationAgency agencyTemplate = evaluationAgencyRepo.findAgencyById(Long.parseLong(agencyId));
         agencyDao.findAll().forEach(evaluationAgencyPO -> {
@@ -822,7 +790,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;
@@ -955,6 +922,20 @@ public class WebMediatorImpl implements ViewMediator {
         return technicalArticlesDTO;
     }
 
+    @Override
+    public IndexInfoDTO getHotTesting() {
+        IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
+        Pageable pageable = PageRequest.of(0, 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());
+        indexInfoDTO.setApplicationTypeRank(applicationTypeRank);
+        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);
+
+    IndexPageDTO getHotTesting(Pageable pageable);
+
+    IndexPageDTO getCompetition(Pageable pageable);
 }

+ 18 - 4
site/src/main/java/com/mooctest/crowd/site/service/impl/CommonServiceImpl.java

@@ -1,9 +1,6 @@
 package com.mooctest.crowd.site.service.impl;
 
-import com.mooctest.crowd.domain.repository.CommonRepo;
-import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
-import com.mooctest.crowd.domain.repository.CrowdTestTaskRepo;
-import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
+import com.mooctest.crowd.domain.repository.*;
 import com.mooctest.crowd.site.data.dto.IndexDTO;
 import com.mooctest.crowd.site.data.dto.IndexInfoDTO;
 import com.mooctest.crowd.site.data.dto.IndexPageDTO;
@@ -38,6 +35,9 @@ public class CommonServiceImpl implements CommonService {
     @Autowired
     private CommonRepo commonRepo;
 
+    @Autowired
+    private ApplicationTypeRepo applicationTypeRepo;
+
 //    @Autowired
 //    private CacheUtil cacheUtil;
 
@@ -86,4 +86,18 @@ public class CommonServiceImpl implements CommonService {
         return   taskRepo.findAllByPage(pageable,keyword,deletedStatus).map(crowdTestTask -> new CrowdTaskVO(crowdTestTask));
     }
 
+    @Override
+    public IndexPageDTO getHotTesting(Pageable pageable) {
+        IndexPageDTO indexPageDTO = new IndexPageDTO();
+        indexPageDTO.setApplicationTypePage(applicationTypeRepo.getHotTesting(pageable).map(applicationType -> new ApplicationTypeVO(applicationType)));
+        return  indexPageDTO;
+    }
+
+    @Override
+    public IndexPageDTO getCompetition(Pageable pageable) {
+        IndexPageDTO indexPageDTO = new IndexPageDTO();
+        indexPageDTO.setCompetitionPage(commonRepo.findAllCompetition(pageable).map(competition -> new CompetitionVO(competition)));
+        return indexPageDTO;
+    }
+
 }

部分文件因文件數量過多而無法顯示