|
@@ -1,4 +1,5 @@
|
|
|
package com.mooctest.crowd.site.mediator.impl;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.mooctest.crowd.domain.dao.*;
|
|
|
import com.mooctest.crowd.domain.domainobject.*;
|
|
@@ -10,6 +11,7 @@ import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
|
import com.mooctest.crowd.domain.repository.EvaluationAgencyRepo;
|
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
|
import com.mooctest.crowd.domain.util.Converter;
|
|
|
+import com.mooctest.crowd.site.command.ApplyEnterpriseAuthCommand;
|
|
|
import com.mooctest.crowd.site.command.ApplyPersonalAuthCommand;
|
|
|
import com.mooctest.crowd.site.command.LoginCommand;
|
|
|
import com.mooctest.crowd.site.command.RegisterCommand;
|
|
@@ -21,6 +23,8 @@ import com.mooctest.crowd.site.data.vo.*;
|
|
|
import com.mooctest.crowd.site.mediator.ViewMediator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.codehaus.jettison.json.JSONException;
|
|
|
+import org.codehaus.jettison.json.JSONObject;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -118,6 +122,30 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
private UserToRoleDao userToRoleDao;
|
|
|
|
|
|
@Override
|
|
|
+ public void saveEnterpriseRole(User user, ApplyEnterpriseAuthCommand applyEnterpriseAuthCommand) {
|
|
|
+ UserPO userPO = userDao.save(Converter.convert(UserPO.class, user));
|
|
|
+ //如果是研发机构那么能发包
|
|
|
+ if(applyEnterpriseAuthCommand.getIsDaOrEa().equals("研发机构")){
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(8L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+
|
|
|
+ }
|
|
|
+ if(applyEnterpriseAuthCommand.getIsDaOrEa().equals("测评机构")){
|
|
|
+ UserToRolePO u2r = new UserToRolePO();
|
|
|
+ u2r.setUserId(userPO.getId());
|
|
|
+ u2r.setRoleId(2L);
|
|
|
+ userToRoleDao.save(u2r);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void saveUserRole(User user, ApplyPersonalAuthCommand command) {
|
|
|
if (command.getRoleList().size() == 0 || command.getRoleList() == null) {
|
|
|
throw new BaseException("请选择成为发包或者接包用户");
|
|
@@ -151,6 +179,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -319,13 +348,7 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
IndexInfoDTO indexInfoDTO = new IndexInfoDTO();
|
|
|
Pageable pageable = PageRequest.of(0, 3);
|
|
|
int top = 3;
|
|
|
- //获取热门众测
|
|
|
- List<ApplicationTypeVO> applicationTypeRank = projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
|
|
|
- ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
|
|
|
- ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
- applicationTypeVO.setCount(rankInfos.getCount());
|
|
|
- return applicationTypeVO;
|
|
|
- }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<ApplicationTypeVO> applicationTypeRank = getApplicationTypeRankVOS(pageable);
|
|
|
List<ApplicationTypeVO> applicationTypeRanks = new ArrayList<>();
|
|
|
if (applicationTypeRanks.size() > top) {
|
|
|
for (int i = 0; i < top; i++) {
|
|
@@ -418,6 +441,17 @@ public class WebMediatorImpl implements ViewMediator {
|
|
|
return indexInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ @NotNull
|
|
|
+ public List<ApplicationTypeVO> getApplicationTypeRankVOS(Pageable pageable) {
|
|
|
+ //获取热门众测
|
|
|
+ return projectDao.findTotalCountOfApplicationType(pageable).stream().map(rankInfos -> {
|
|
|
+ ApplicationType applicationType = commonRepo.getApplicationTypeByAppCode(rankInfos.getCode());
|
|
|
+ ApplicationTypeVO applicationTypeVO = new ApplicationTypeVO(applicationType);
|
|
|
+ applicationTypeVO.setCount(rankInfos.getCount());
|
|
|
+ return applicationTypeVO;
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public IndexDTO renderIndex() {
|
|
|
Pageable pageable = PageRequest.of(0, 10);
|