Explorar o código

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

git %!s(int64=5) %!d(string=hai) anos
pai
achega
13ce576081

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/data/dto/CrowdTestSquareIndexDTO.java

@@ -40,7 +40,7 @@ public class CrowdTestSquareIndexDTO {
         this.hotCrowdTestProjectVOs = list1.subList(0, 7);
         List<CrowdTaskVO> tasklist1 = crowdTestTaskVOS.stream().sorted(Comparator.comparing(CrowdTaskVO::getCreateTime).reversed()).collect(Collectors.toList());
         this.crowdTestTaskVOS=tasklist1.subList(0,6);
-        List<CrowdTaskVO> tasklist2 = tasklist1.stream().sorted(Comparator.comparing(CrowdTaskVO::getParticipantCount).reversed()).collect(Collectors.toList());
+        List<CrowdTaskVO> tasklist2 = tasklist1.stream().sorted(Comparator.comparing(CrowdTaskVO::getAcceptedCount).reversed()).collect(Collectors.toList());
         //过滤掉已完成的
         tasklist2.stream().filter(ct -> ct.getStatus() != CrowdTestTaskStatus.HAS_FINISHED);
         this.hotCrowdTaskVOs = tasklist2.subList(0, 7);

+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/CrowdTaskVO.java

@@ -39,6 +39,7 @@ public class CrowdTaskVO implements Serializable {
     private Timestamp datetime;
     private int participantCount;
     private int acceptedCount;
+    private int joinCount;
     private int participantHasCommittedCount;
     private StatusVO statusVO;
     private FullStatusVO fullStatusVO;
@@ -69,6 +70,7 @@ public class CrowdTaskVO implements Serializable {
         datetime = task.getDeadTime();
         participantCount = task.getParticipantCount();
         acceptedCount = task.getAcceptedCount();
+        joinCount = task.getAcceptedCount();
         createTime = task.getCreateTime();
         participantHasCommittedCount = task.getParticipantHasCommittedCount();
         DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 59 - 52
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -43,6 +43,8 @@ import java.util.stream.Collectors;
 @Slf4j
 @Component("WebMediator")
 public class WebMediatorImpl implements ViewMediator {
+    @Autowired
+    private TestTypeDao testTypeDao;
 
     @Autowired
     private CrowdTestProjectRepo projectRepo;
@@ -53,6 +55,7 @@ public class WebMediatorImpl implements ViewMediator {
     @Autowired
     private EvaluationAgencyRepo evaluationAgencyRepo;
 
+
     @Autowired
     private CommonRepo commonRepo;
     @Autowired
@@ -92,10 +95,10 @@ public class WebMediatorImpl implements ViewMediator {
     private QualificationDao qualificationDao;
 
     @Autowired
-    private  BankCardDao bankCardDao;
+    private BankCardDao bankCardDao;
 
     @Autowired
-    private  BankLogoDao bankLogoDao;
+    private BankLogoDao bankLogoDao;
 
     @Autowired
     private UploadService uploadService;
@@ -105,34 +108,34 @@ public class WebMediatorImpl implements ViewMediator {
 
     @Override
     public EnterpriseAuthVO getEnterpriseAuthByUserId(Long userId) {
-        EnterpriseAuthentication enterpriseAuthentication=new EnterpriseAuthentication();
-        EnterpriseAuthenticationPO enterpriseAuthenticationPO=enterpriseAuthenticationDao.findByUserId(userId);
-        if(enterpriseAuthenticationPO==null){
-            throw new  BaseException("当前用户没有企业认证信息");
+        EnterpriseAuthentication enterpriseAuthentication = new EnterpriseAuthentication();
+        EnterpriseAuthenticationPO enterpriseAuthenticationPO = enterpriseAuthenticationDao.findByUserId(userId);
+        if (enterpriseAuthenticationPO == null) {
+            throw new BaseException("当前用户没有企业认证信息");
         }
         enterpriseAuthentication.getByPo(enterpriseAuthenticationPO);
-        EnterpriseAuthVO enterpriseAuthVO=new EnterpriseAuthVO(enterpriseAuthentication);
-        return  enterpriseAuthVO;
+        EnterpriseAuthVO enterpriseAuthVO = new EnterpriseAuthVO(enterpriseAuthentication);
+        return enterpriseAuthVO;
 
 
     }
 
     @Override
     public PersonalAuthVO getByUserId(Long userId) {
-        PersonalAuthentication personalAuthentication=new PersonalAuthentication();
-        PersonalAuthenticationPO personalAuthenticationPO=personalAuthenticationDao.findByUserId(userId);
-        if(personalAuthenticationPO==null){
-            throw  new BaseException("当前用户没有认证信息");
+        PersonalAuthentication personalAuthentication = new PersonalAuthentication();
+        PersonalAuthenticationPO personalAuthenticationPO = personalAuthenticationDao.findByUserId(userId);
+        if (personalAuthenticationPO == null) {
+            throw new BaseException("当前用户没有认证信息");
         }
         personalAuthentication.getByPo(personalAuthenticationDao.findByUserId(userId));
-        PersonalAuthVO personalAuthVO=new PersonalAuthVO(personalAuthentication);
-          return  personalAuthVO;
+        PersonalAuthVO personalAuthVO = new PersonalAuthVO(personalAuthentication);
+        return personalAuthVO;
 
     }
 
     @Override
     public UserDTO loginByMobileAndPwd(LoginCommand cmd) {
-          return null;
+        return null;
     }
 
     @Override
@@ -154,10 +157,10 @@ public class WebMediatorImpl implements ViewMediator {
         }).filter(Objects::nonNull).collect(Collectors.toList());
         List<ApplicationTypeVO> applicationTypeRanks = new ArrayList<>();
         if (applicationTypeRanks.size() > top) {
-            for(int i = 0; i < top; i++){
+            for (int i = 0; i < top; i++) {
                 applicationTypeRanks.add(applicationTypeRank.get(i));
             }
-        }else{
+        } else {
             applicationTypeRanks = applicationTypeRank;
         }
 
@@ -178,10 +181,10 @@ public class WebMediatorImpl implements ViewMediator {
         }).filter(Objects::nonNull).collect(Collectors.toList());
         List<EvolutionAgencyVO> agencyRanks = new ArrayList<>();
         if (agencyRank.size() > top) {
-            for(int i = 0; i < top; i++){
+            for (int i = 0; i < top; i++) {
                 agencyRanks.add(agencyRank.get(i));
             }
-        }else{
+        } else {
             agencyRanks = agencyRank;
         }
 
@@ -198,10 +201,10 @@ public class WebMediatorImpl implements ViewMediator {
         }).filter(Objects::nonNull).collect(Collectors.toList());
         List<UserVO> userRanks = new ArrayList<>();
         if (userRank.size() > top) {
-            for(int i = 0; i < top; i++){
+            for (int i = 0; i < top; i++) {
                 userRanks.add(userRank.get(i));
             }
-        }else{
+        } else {
             userRanks = userRank;
         }
 
@@ -209,10 +212,10 @@ public class WebMediatorImpl implements ViewMediator {
         List<Competition> competitionList = commonRepo.getAllCompetition();
         List<Competition> competitionLists = new ArrayList<>();
         if (competitionList.size() > top) {
-            for(int i = 0; i < top; i++){
+            for (int i = 0; i < top; i++) {
                 competitionLists.add(competitionList.get(i));
             }
-        }else{
+        } else {
             competitionLists = competitionList;
         }
 
@@ -725,7 +728,7 @@ public class WebMediatorImpl implements ViewMediator {
     @Override
     public List<CrowdTestProjectVO> findByNameLike(String name) {
         List<CrowdTestProjectVO> authingList = new ArrayList<>();
-        authingList.addAll(projectDao.findByNameLike("%"+name+"%").stream().map(crowdTestProjectPO -> {
+        authingList.addAll(projectDao.findByNameLike("%" + name + "%").stream().map(crowdTestProjectPO -> {
             CrowdTestProject crowdTestProject = new CrowdTestProject();
             BeanUtils.copyProperties(crowdTestProjectPO, crowdTestProject);
             return new CrowdTestProjectVO(crowdTestProject);
@@ -736,7 +739,7 @@ public class WebMediatorImpl implements ViewMediator {
     @Override
     public List<CrowdTaskVO> findTaskByNameLike(String name) {
         List<CrowdTaskVO> authingList = new ArrayList<>();
-        authingList.addAll(taskDao.findByNameLike("%"+name+"%").stream().map(crowdTestTaskPO -> {
+        authingList.addAll(taskDao.findByNameLike("%" + name + "%").stream().map(crowdTestTaskPO -> {
             CrowdTestTask crowdTestTask = new CrowdTestTask();
             BeanUtils.copyProperties(crowdTestTaskPO, crowdTestTask);
             return new CrowdTaskVO(crowdTestTask);
@@ -751,6 +754,7 @@ public class WebMediatorImpl implements ViewMediator {
             CrowdTestProject crowdTestProject = new CrowdTestProject();
             BeanUtils.copyProperties(crowdTestProjectPO, crowdTestProject);
             return new CrowdTestProjectVO(crowdTestProject);
+
         }).collect(Collectors.toList()));
         return authingList;
     }
@@ -758,11 +762,13 @@ public class WebMediatorImpl implements ViewMediator {
     @Override
     public List<CrowdTaskVO> crowdTaskVos() {
 
-
         List<CrowdTaskVO> authingList = new ArrayList<>();
         authingList.addAll(taskDao.findAll().stream().map(crowdTestTaskPO -> {
+            //根据code值查询出来该任务的type
+            Optional<TestTypePO> serviceType = testTypeDao.findByCode(crowdTestTaskPO.getType());
             CrowdTestTask crowdTestTask = new CrowdTestTask();
             BeanUtils.copyProperties(crowdTestTaskPO, crowdTestTask);
+            crowdTestTask.setType(serviceType.get().getName());
             return new CrowdTaskVO(crowdTestTask);
         }).collect(Collectors.toList()));
         return authingList;
@@ -770,7 +776,7 @@ public class WebMediatorImpl implements ViewMediator {
 
     @Override
     public UserDTO getInformation(long userId) {
-        UserDTO userDTO=new UserDTO();
+        UserDTO userDTO = new UserDTO();
         Optional<UserPO> userPO = userDao.findById(userId);
         if (userPO.isPresent()) {
             UserVO userVO = new UserVO();
@@ -794,23 +800,23 @@ public class WebMediatorImpl implements ViewMediator {
     @Override
     public UserDTO updateInformation(long userId, UserVO userVO) {
         Optional<UserPO> userPO = userDao.findById(userId);
-            userPO.get().setUnit(userVO.getUnit());
-            userPO.get().setGender(userVO.getGender());
-            userPO.get().setBirthday(userVO.getBirthday());
-            userPO.get().setProvince(userVO.getProvince());
-            userPO.get().setCity(userVO.getCity());
-            userPO.get().setCounty(userVO.getCounty());
-            userPO.get().setDetailedAddress(userVO.getDetailedAddress());
-            userPO.get().setPersonalCompetence(userVO.getPersonalCompetence());
-            userDao.save(userPO.get());
+        userPO.get().setUnit(userVO.getUnit());
+        userPO.get().setGender(userVO.getGender());
+        userPO.get().setBirthday(userVO.getBirthday());
+        userPO.get().setProvince(userVO.getProvince());
+        userPO.get().setCity(userVO.getCity());
+        userPO.get().setCounty(userVO.getCounty());
+        userPO.get().setDetailedAddress(userVO.getDetailedAddress());
+        userPO.get().setPersonalCompetence(userVO.getPersonalCompetence());
+        userDao.save(userPO.get());
         return this.getInformation(userId);
     }
 
     @Override
     public QualificationDTO getQualification(long userId) {
-        QualificationDTO qualificationDTO=new QualificationDTO();
+        QualificationDTO qualificationDTO = new QualificationDTO();
         List<QualificationVO> qualificationVOList = new ArrayList<>();
-        qualificationDao.findByUserIdAndIsDeleted(userId,DeletedStatus.isNotDeleted).forEach(qualificationPO ->{
+        qualificationDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted).forEach(qualificationPO -> {
             QualificationVO qualificationVO = new QualificationVO();
             qualificationVO.setId(qualificationPO.getId());
             qualificationVO.setName(qualificationPO.getName());
@@ -826,8 +832,8 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public QualificationDTO addQualification(long userId,QualificationVO qualificationVO) {
-        QualificationPO  qualificationPO=new QualificationPO();
+    public QualificationDTO addQualification(long userId, QualificationVO qualificationVO) {
+        QualificationPO qualificationPO = new QualificationPO();
         qualificationPO.setName(qualificationVO.getName());
         qualificationPO.setNumber(qualificationVO.getNumber());
         qualificationPO.setLicensingAuthority(qualificationVO.getLicensingAuthority());
@@ -839,8 +845,8 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public QualificationDTO updateQualification(long id, long userId,QualificationVO qualificationVO) {
-        Optional<QualificationPO> qualificationPO=qualificationDao.findById(id);
+    public QualificationDTO updateQualification(long id, long userId, QualificationVO qualificationVO) {
+        Optional<QualificationPO> qualificationPO = qualificationDao.findById(id);
         qualificationPO.get().setName(qualificationVO.getName());
         qualificationPO.get().setNumber(qualificationVO.getNumber());
         qualificationPO.get().setLicensingAuthority(qualificationVO.getLicensingAuthority());
@@ -852,7 +858,7 @@ public class WebMediatorImpl implements ViewMediator {
 
     @Override
     public QualificationDTO deleteQualification(long id, long userId) {
-        Optional<QualificationPO> qualificationPO=qualificationDao.findById(id);
+        Optional<QualificationPO> qualificationPO = qualificationDao.findById(id);
         qualificationPO.get().setIsDeleted(1);
         qualificationDao.save(qualificationPO.get());
         return this.getQualification(userId);
@@ -860,14 +866,14 @@ public class WebMediatorImpl implements ViewMediator {
 
     @Override
     public BankCardDTO getBankCard(long userId) {
-        BankCardDTO bankCardDTO=new BankCardDTO();
+        BankCardDTO bankCardDTO = new BankCardDTO();
         List<BankCardVO> bankCardVOList = new ArrayList<>();
-        bankCardDao.findByUserIdAndIsDeleted(userId,DeletedStatus.isNotDeleted).forEach(bankCardPO ->{
+        bankCardDao.findByUserIdAndIsDeleted(userId, DeletedStatus.isNotDeleted).forEach(bankCardPO -> {
             BankCardVO bankCardVO = new BankCardVO();
             bankCardVO.setId(bankCardPO.getId());
             bankCardVO.setUser(bankCardPO.getUser());
             bankCardVO.setNumber(bankCardPO.getNumber());
-            Optional<BankLogoPO> bankLogo=bankLogoDao.findByCode(bankCardPO.getCode());
+            Optional<BankLogoPO> bankLogo = bankLogoDao.findByCode(bankCardPO.getCode());
             bankCardVO.setLogoUrl(bankLogo.get().getLogoUrl());
             bankCardVO.setName(bankLogo.get().getName());
             bankCardVOList.add(bankCardVO);
@@ -879,11 +885,11 @@ public class WebMediatorImpl implements ViewMediator {
 
     @Override
     public BankCardDTO addBankCard(long userId, BankCardVO bankCardVO) throws JSONException {
-        BankCardPO bankCardPO=new BankCardPO();
-        String bankNo=bankCardVO.getNumber();
-        String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo="+bankNo+"&cardBinCheck=true";
+        BankCardPO bankCardPO = new BankCardPO();
+        String bankNo = bankCardVO.getNumber();
+        String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=" + bankNo + "&cardBinCheck=true";
         RestTemplate restTemplate = new RestTemplate();
-        String result = restTemplate.getForObject(url,String.class);
+        String result = restTemplate.getForObject(url, String.class);
         JSONObject json = new JSONObject(result);
         String validated = String.valueOf(json.get("validated"));
         if("false".equals(validated)){
@@ -902,9 +908,10 @@ public class WebMediatorImpl implements ViewMediator {
         //bankCardDao.save(bankCardPO);
         return this.getBankCard(userId);
     }
+
     @Override
     public BankCardDTO deleteBankCard(long id, long userId) {
-        Optional<BankCardPO> bankCardPO=bankCardDao.findById(id);
+        Optional<BankCardPO> bankCardPO = bankCardDao.findById(id);
         bankCardPO.get().setIsDeleted(1);
         bankCardDao.save(bankCardPO.get());
         return this.getBankCard(userId);
@@ -913,7 +920,7 @@ public class WebMediatorImpl implements ViewMediator {
     @Override
     public TechnicalArticlesDTO updateRanking(long id) {
         int i = technicalarticlesDao.updateReading(id);
-        TechnicalArticlesDTO technicalArticlesDTO=new TechnicalArticlesDTO();
+        TechnicalArticlesDTO technicalArticlesDTO = new TechnicalArticlesDTO();
         technicalArticlesDTO.setCount(i);
         return technicalArticlesDTO;
     }

+ 4 - 2
site/src/main/java/com/mooctest/crowd/site/service/impl/CrowdProjectServiceImpl.java

@@ -31,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -62,9 +63,10 @@ public class CrowdProjectServiceImpl implements CrowdProjectService {
     @Override
     public List<CrowdTestProjectVO> findByNameLike(String name) {
         if(name==null||name.trim().equals("")){
-            return  viewMediator.crowdTestProjects();
+            return  viewMediator.crowdTestProjects().stream().sorted(Comparator.comparing(CrowdTestProjectVO::getCreateTime).reversed()).collect(Collectors.toList());
         }
-       return  viewMediator.findByNameLike(name);
+       return  viewMediator.findByNameLike(name).stream().sorted(Comparator.comparing(CrowdTestProjectVO::getCreateTime).reversed()).collect(Collectors.toList());
+
 
 
     }

+ 5 - 2
site/src/main/java/com/mooctest/crowd/site/service/impl/CrowdTaskServiceImpl.java

@@ -24,8 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 
+import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author: Diors.Po
@@ -64,9 +66,10 @@ public class CrowdTaskServiceImpl implements CrowdTaskService {
     @Override
     public List<CrowdTaskVO> findByNameLike(String name) {
         if(name==null||name.trim().equals("")){
-            return  viewMediator.crowdTaskVos();
+            return  viewMediator.crowdTaskVos().stream().sorted(Comparator.comparing(CrowdTaskVO::getCreateTime).reversed()).collect(Collectors.toList());
         }
-       return  viewMediator.findTaskByNameLike(name);
+       return  viewMediator.findTaskByNameLike(name).stream().sorted(Comparator.comparing(CrowdTaskVO::getCreateTime).reversed()).collect(Collectors.toList());
+
 
     }
 

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

@@ -141,7 +141,7 @@ website:
 spring:
   profiles: pre
   datasource:
-    url: jdbc:mysql://101.37.175.111:3306/crowd-test-service?useSSL=false&useUnicode=yes&characterEncoding=UTF-8
+    url: jdbc:mysql://101.37.175.111:3306/crowd-test-service?useSSL=false&useUnicode=yes&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
     username: mooctest
     password: secr3t!
   redis: