|
@@ -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 {
|