|
|
@@ -1,17 +1,23 @@
|
|
|
package com.mooctest.crowd.site.mediator.impl;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.dao.EvaluationAgencyDao;
|
|
|
import com.mooctest.crowd.domain.domainobject.CrowdTestProject;
|
|
|
+import com.mooctest.crowd.domain.domainobject.CrowdTestTask;
|
|
|
+import com.mooctest.crowd.domain.domainobject.CrowdTestTaskStatus;
|
|
|
+import com.mooctest.crowd.domain.domainobject.EvaluationAgency;
|
|
|
import com.mooctest.crowd.domain.exception.AccountNotExistException;
|
|
|
import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
|
+import com.mooctest.crowd.domain.repository.UserRepo;
|
|
|
import com.mooctest.crowd.site.command.*;
|
|
|
import com.mooctest.crowd.site.data.dto.*;
|
|
|
-import com.mooctest.crowd.site.data.vo.CrowdProjectVO;
|
|
|
-import com.mooctest.crowd.site.data.vo.CrowdReportVO;
|
|
|
-import com.mooctest.crowd.site.data.vo.CrowdTaskVO;
|
|
|
+import com.mooctest.crowd.site.data.vo.*;
|
|
|
import com.mooctest.crowd.site.mediator.ViewMediator;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -25,6 +31,12 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
@Autowired
|
|
|
private CrowdTestProjectRepo projectRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserRepo userRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EvaluationAgencyDao agencyDao;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public UserDTO loginByMobileAndPwd(LoginCommand cmd) {
|
|
|
@@ -38,7 +50,65 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
|
|
|
@Override
|
|
|
public IndexDTO renderIndex() {
|
|
|
- return new IndexDTO();
|
|
|
+ ArrayList<CrowdTaskVO> hotTasks = new ArrayList<>();
|
|
|
+ projectRepo.getAllCrowdTestProject().forEach(project -> {
|
|
|
+ hotTasks.addAll(project.getCrowdTestTaskList()
|
|
|
+ .stream().filter(crowdTestTask -> crowdTestTask.getStatus() == CrowdTestTaskStatus.HAS_RELEASED)
|
|
|
+ .map(crowdTestTask -> new CrowdTaskVO(crowdTestTask)).collect(Collectors.toList()));
|
|
|
+ });
|
|
|
+ List<UserVO> userRank = userRepo.getAllUser().stream().map(user -> new UserVO(user)).collect(Collectors.toList());
|
|
|
+ hotTasks.sort(Comparator.comparing(CrowdTaskVO::getQuotePrice));
|
|
|
+ List<EvolutionAgencyVO> agencyVOS = new ArrayList<>();
|
|
|
+
|
|
|
+ EvolutionAgencyVO agency1 = new EvolutionAgencyVO();
|
|
|
+ agency1.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency1.setName("agency1");
|
|
|
+ EvolutionAgencyVO agency2 = new EvolutionAgencyVO();
|
|
|
+ agency2.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency2.setName("agency2");
|
|
|
+ EvolutionAgencyVO agency3 = new EvolutionAgencyVO();
|
|
|
+ agency3.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency3.setName("agency3");
|
|
|
+ EvolutionAgencyVO agency4 = new EvolutionAgencyVO();
|
|
|
+ agency4.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency4.setName("agency4");
|
|
|
+ EvolutionAgencyVO agency5 = new EvolutionAgencyVO();
|
|
|
+ agency5.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency5.setName("agency5");
|
|
|
+ EvolutionAgencyVO agency6 = new EvolutionAgencyVO();
|
|
|
+ agency6.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency6.setName("agency6");
|
|
|
+ EvolutionAgencyVO agency7 = new EvolutionAgencyVO();
|
|
|
+ agency7.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency7.setName("agency7");
|
|
|
+ EvolutionAgencyVO agency8 = new EvolutionAgencyVO();
|
|
|
+ agency8.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency8.setName("agency8");
|
|
|
+ EvolutionAgencyVO agency9 = new EvolutionAgencyVO();
|
|
|
+ agency9.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency9.setName("agency9");
|
|
|
+ EvolutionAgencyVO agency10 = new EvolutionAgencyVO();
|
|
|
+ agency10.setLogo("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ agency10.setName("agency10");
|
|
|
+ agencyVOS.add(agency1);
|
|
|
+ agencyVOS.add(agency2);
|
|
|
+ agencyVOS.add(agency3);
|
|
|
+ agencyVOS.add(agency4);
|
|
|
+ agencyVOS.add(agency5);
|
|
|
+ agencyVOS.add(agency6);
|
|
|
+ agencyVOS.add(agency7);
|
|
|
+ agencyVOS.add(agency8);
|
|
|
+ agencyVOS.add(agency9);
|
|
|
+ agencyVOS.add(agency10);
|
|
|
+ IndexDTO indexDTO = new IndexDTO();
|
|
|
+ indexDTO.setHotTaskList(hotTasks);
|
|
|
+ indexDTO.setUserRank(userRank);
|
|
|
+ indexDTO.setAgencyRank(agencyVOS);
|
|
|
+ List<String> img = new ArrayList<>();
|
|
|
+ img.add("http://www.mooctest.net/assets/img/mooctest.png");
|
|
|
+ img.add("https://docs.alibabagroup.com/assets2/images/cn/global/logo_header.png");
|
|
|
+ indexDTO.setImgList(img);
|
|
|
+ return indexDTO;
|
|
|
}
|
|
|
|
|
|
@Override
|