Browse Source

修改找机构和机构排行榜更多,查看所有机构信息

郭超 4 years ago
parent
commit
0b3dec78af

+ 19 - 14
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -5,7 +5,6 @@ import com.mooctest.crowd.domain.domainobject.*;
 import com.mooctest.crowd.domain.exception.BaseException;
 import com.mooctest.crowd.domain.exception.EvaluationAgencyNotExistException;
 import com.mooctest.crowd.domain.exception.UserNotExistException;
-import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
 import com.mooctest.crowd.domain.model.UserTaskCountPO;
 import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
 import com.mooctest.crowd.domain.repository.UserRepo;
@@ -137,19 +136,25 @@ public class AgencyServiceImpl implements AgencyService {
      */
     @Override
     public List<EvaluationAgencyVO> findMoreAgencyVO(String keyword) {
-        List<EvaluationAgencyVO> list = userTaskCountDao.findByType(RoleType.AGENCY.getId())
-                .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount)).collect(Collectors.toList())
-                .stream().map(userTaskCountPO -> {
-                    EvaluationAgencyPO agency = agencyDao.findByUserId(userTaskCountPO.getUserId());
-                    EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
-                    agencyVO.setAgencyPhoto(agency.getAgencyPhoto());
-                    agencyVO.setTaskCount(userTaskCountPO.getCount());
-                    agencyVO.setId(agency.getId());
-                    agencyVO.setUserId(agency.getUserId());
-                    agencyVO.setEvaluationAgencyName(agency.getEvaluationAgencyName());
-                    agencyVO.setAddress(agency.getAddress());
-                    return agencyVO;
-                }).collect(Collectors.toList());
+        List<UserTaskCountPO> userTaskCountPOList = userTaskCountDao.findByType(RoleType.AGENCY.getId());
+        List<Long> agencyIdList = userTaskCountPOList.stream().map(UserTaskCountPO::getUserId).collect(Collectors.toList());
+
+        List<EvaluationAgency> evaluationAgencyList = evaluationAgencyRepo.findAll();
+        List<EvaluationAgencyVO> list = evaluationAgencyList.stream().map(agency -> {
+            EvaluationAgencyVO agencyVO = new EvaluationAgencyVO();
+            if(agencyIdList.indexOf(agency.getUserId()) != -1){
+                agencyVO.setTaskCount(userTaskCountPOList.get(agencyIdList.indexOf(agency.getUserId())).getCount());
+            }else{
+                agencyVO.setTaskCount(0L);
+            }
+            agencyVO.setAgencyPhoto(agency.getAgencyPhoto());
+            agencyVO.setId(agency.getId());
+            agencyVO.setUserId(agency.getUserId());
+            agencyVO.setEvaluationAgencyName(agency.getEvaluationAgencyName());
+            agencyVO.setAddress(agency.getAddress());
+            return agencyVO;
+        }).collect(Collectors.toList());
+
         if (keyword == null) {
             return list.stream().sorted(Comparator.comparing(EvaluationAgencyVO::getTaskCount).reversed()).collect(Collectors.toList());
         } else {

+ 1 - 1
site/src/main/resources/application.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-     active: pre-online
+     active: dev-online
   cache:
     guava:
       spec: expireAfterWrite=30s