|
@@ -8,6 +8,7 @@ import com.mooctest.crowd.domain.exception.CrowdTestTaskNotExistException;
|
|
|
import com.mooctest.crowd.domain.exception.HttpBadRequestException;
|
|
|
import com.mooctest.crowd.domain.factory.CrowdTestProjectFactory;
|
|
|
import com.mooctest.crowd.domain.model.*;
|
|
|
+import com.mooctest.crowd.domain.repository.CommonRepo;
|
|
|
import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
|
import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
|
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
@@ -49,6 +50,9 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
private EvaluationAgencyRepo evaluationAgencyRepo;
|
|
|
|
|
|
@Autowired
|
|
|
+ private CommonRepo commonRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private CrowdTestTaskDao taskDao;
|
|
|
|
|
|
@Autowired
|
|
@@ -93,7 +97,100 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Override
|
|
|
public IndexInfoDTO renderIndexInfos() {
|
|
|
- return null;
|
|
|
+ IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
+ Pageable pageable = PageRequest.of(0, 3);
|
|
|
+ //获取用户排名
|
|
|
+ List<UserVO> userRanks = projectDao.findTotalPriceOfUser(pageable).stream().map(rankInfo -> {
|
|
|
+ Optional<UserPO> userPO = userDao.findById(rankInfo.getEntityId());
|
|
|
+ if (userPO.isPresent()) {
|
|
|
+ UserVO userVO = new UserVO();
|
|
|
+ userVO.setName(userPO.get().getName());
|
|
|
+ userVO.setUserName(userPO.get().getUserName());
|
|
|
+ userVO.setAllProjectPrice(rankInfo.getTotalPrice());
|
|
|
+ return userVO;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ //获取机构排名
|
|
|
+ String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
+ List<EvolutionAgencyVO> agencyRanks = taskToUserDao.findTotalPriceOfAgency(pageable).stream().map(rankInfo -> {
|
|
|
+ EvaluationAgencyPO agency = agencyDao.findByUserId(rankInfo.getEntityId());
|
|
|
+ if (agency!=null && !agency.getEvaluationAgencyName().equals(agencyName)) {
|
|
|
+ EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
+ agencyVO.setName(agency.getEvaluationAgencyName());
|
|
|
+ agencyVO.setLogo(agency.getAgencyPhoto());
|
|
|
+ agencyVO.setAllTaskPrice(rankInfo.getTotalPrice());
|
|
|
+ return agencyVO;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取服务类型
|
|
|
+ List<TestType> allTestType = commonRepo.getAllTestType();
|
|
|
+ List<TestTypeVO> testTypeVOS = allTestType.stream().map(testType -> {
|
|
|
+ TestTypeVO testTypeVO = new TestTypeVO(testType);
|
|
|
+ return testTypeVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取应用类型
|
|
|
+ List<ApplicationType> allApplicationType = commonRepo.getAllApplicationType();
|
|
|
+ List<ApplicationTypeVO> applicationTypeVOS = allApplicationType.stream().map(applicationType -> {
|
|
|
+ ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
+ List<TestType> testTypeList = commonRepo.getTestTypeListByAppCode(applicationType.getCode());
|
|
|
+ List<TestTypeVO> typeVOS = testTypeList.stream().map(testType -> {
|
|
|
+ TestTypeVO testTypeVO = new TestTypeVO(testType);
|
|
|
+ return testTypeVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ applicationTypeVO.setTestTypeList(typeVOS);
|
|
|
+ return applicationTypeVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取领域划分
|
|
|
+ List<Field> fieldList = commonRepo.getAllFieldType();
|
|
|
+ List<FieldVO> fieldVOS = fieldList.stream().map(field -> {
|
|
|
+ FieldVO fieldVO = new FieldVO(field);
|
|
|
+ return fieldVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取大赛信息
|
|
|
+ List<Competition> competitionList = commonRepo.getAllCompetition();
|
|
|
+ List<CompetitionVO> competitionVOS = competitionList.stream().map(competition -> {
|
|
|
+ CompetitionVO competitionVO = new CompetitionVO(competition);
|
|
|
+ return competitionVO;
|
|
|
+ }).sorted(Comparator.comparing(CompetitionVO::getStartTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取资源和工具
|
|
|
+ List<Resource> resourceList = commonRepo.getAllResource();
|
|
|
+ List<ResourceVO> resourceVOS = resourceList.stream().map(resource -> {
|
|
|
+ ResourceVO resourceVO = new ResourceVO(resource);
|
|
|
+ return resourceVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取入驻品牌机构
|
|
|
+ List<Partner> partnerList = commonRepo.getAllPartner();
|
|
|
+ List<PartnerVO> partnerVOS = partnerList.stream().map(partner -> {
|
|
|
+ PartnerVO partnerVO = new PartnerVO(partner);
|
|
|
+ return partnerVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 获取合作机构
|
|
|
+ List<ResidentAgency> allResidentAgency = commonRepo.getAllResidentAgency();
|
|
|
+ List<EvolutionAgencyVO> agencyVOS = allResidentAgency.stream().map(residentAgency -> {
|
|
|
+ EvaluationAgency agency = evaluationAgencyRepo.findAgencyById(residentAgency.getAgencyId());
|
|
|
+ EvolutionAgencyVO evolutionAgencyVO = new EvolutionAgencyVO(agency);
|
|
|
+ return evolutionAgencyVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ indexInfoDTO.setAgencyRank(agencyRanks);
|
|
|
+ indexInfoDTO.setUserRank(userRanks);
|
|
|
+ indexInfoDTO.setTestTypeList(testTypeVOS);
|
|
|
+ indexInfoDTO.setApplicationTypeList(applicationTypeVOS);
|
|
|
+ indexInfoDTO.setFieldList(fieldVOS);
|
|
|
+ indexInfoDTO.setCompetitionList(competitionVOS);
|
|
|
+ indexInfoDTO.setResourceList(resourceVOS);
|
|
|
+ indexInfoDTO.setResidentAgencyList(agencyVOS);
|
|
|
+ indexInfoDTO.setPartnerList(partnerVOS);
|
|
|
+ return indexInfoDTO;
|
|
|
}
|
|
|
|
|
|
@Override
|