|
@@ -6,6 +6,7 @@ import com.mooctest.crowd.domain.dao.UserDao;
|
|
|
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.HttpBadRequestException;
|
|
|
import com.mooctest.crowd.domain.exception.UserNotExistException;
|
|
|
import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
|
|
|
import com.mooctest.crowd.domain.model.RankCountInfo;
|
|
@@ -19,12 +20,11 @@ import com.mooctest.crowd.site.command.ApplyAgencyAuthCommand;
|
|
|
import com.mooctest.crowd.site.command.GenerateAgencyCommand;
|
|
|
import com.mooctest.crowd.site.data.dto.UserDTO;
|
|
|
import com.mooctest.crowd.site.data.vo.AgencyVO;
|
|
|
-import com.mooctest.crowd.site.data.vo.EvolutionAgencyVO;
|
|
|
+import com.mooctest.crowd.site.data.vo.EvaluationAgencyVO;
|
|
|
import com.mooctest.crowd.site.data.vo.UserVO;
|
|
|
import com.mooctest.crowd.site.mediator.ViewMediator;
|
|
|
import com.mooctest.crowd.site.service.AgencyService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -66,28 +66,30 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
private String agencyId;
|
|
|
|
|
|
@Override
|
|
|
- public EvolutionAgencyVO getDetailById(long agencyId) {
|
|
|
+ public EvaluationAgencyVO getDetailById(long agencyId) {
|
|
|
/*
|
|
|
先根据机构id查询出机构信息,再从task-to-user表里面找到这个机构的接的任务的数量。
|
|
|
*/
|
|
|
- EvaluationAgencyPO agencyPO = agencyDao.findByUserId(agencyId);
|
|
|
- EvolutionAgencyVO agencyVO = new EvolutionAgencyVO();
|
|
|
+ Optional<EvaluationAgencyPO> agencyPO = agencyDao.findById(agencyId);
|
|
|
+ if(!agencyPO.isPresent()){
|
|
|
+ throw new HttpBadRequestException("机构不存在!");
|
|
|
+ }
|
|
|
+ EvaluationAgency evaluationAgency = new EvaluationAgency(agencyPO.get());
|
|
|
+ EvaluationAgencyVO agencyVO = new EvaluationAgencyVO(evaluationAgency);
|
|
|
List<RankCountInfo> rankCountInfoList = taskToUserDao.findTotalCountOfUser();
|
|
|
long ids[] = new long[rankCountInfoList.size()];
|
|
|
for (int i = 0; i < ids.length; i++) {
|
|
|
ids[i] = rankCountInfoList.get(i).getEntityId();
|
|
|
- if (ids[i] == agencyId) {
|
|
|
+ if (ids[i] == agencyVO.getUserId()) {
|
|
|
agencyVO.setTaskCount(rankCountInfoList.get(i).getCount());
|
|
|
}
|
|
|
}
|
|
|
- BeanUtils.copyProperties(agencyPO, agencyVO);
|
|
|
-
|
|
|
return agencyVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<EvolutionAgencyVO> findMoreAgencyVO(String keyword) {
|
|
|
- List<EvolutionAgencyVO> list = new ArrayList<EvolutionAgencyVO>();//机构列表
|
|
|
+ public List<EvaluationAgencyVO> findMoreAgencyVO(String keyword) {
|
|
|
+ List<EvaluationAgencyVO> list = new ArrayList<EvaluationAgencyVO>();//机构列表
|
|
|
List<RankCountInfo> rankInfos = taskToUserDao.findTotalCountOfUser();//用户接包信息
|
|
|
String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
|
|
|
for (int i = 0; i < rankInfos.size(); i++) {
|
|
@@ -100,13 +102,13 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
}
|
|
|
}
|
|
|
EvaluationAgency evaluationAgency = new EvaluationAgency(evaluationAgencyPO);
|
|
|
- EvolutionAgencyVO evolutionAgencyVO = new EvolutionAgencyVO(evaluationAgency);
|
|
|
- evolutionAgencyVO.setTaskCount(rankInfos.get(i).getCount());
|
|
|
- evolutionAgencyVO.setAddress((user.get().getProvince() + user.get().getCity()).replaceAll("null", ""));
|
|
|
- list.add(evolutionAgencyVO);
|
|
|
+ EvaluationAgencyVO evalutionAgencyVO = new EvaluationAgencyVO(evaluationAgency);
|
|
|
+ evalutionAgencyVO.setTaskCount(rankInfos.get(i).getCount());
|
|
|
+ evalutionAgencyVO.setAddress((user.get().getProvince() + user.get().getCity()).replaceAll("null", ""));
|
|
|
+ list.add(evalutionAgencyVO);
|
|
|
}
|
|
|
}
|
|
|
- return list.stream().sorted(Comparator.comparing(EvolutionAgencyVO::getTaskCount).reversed()).collect(Collectors.toList());
|
|
|
+ return list.stream().sorted(Comparator.comparing(EvaluationAgencyVO::getTaskCount).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -178,7 +180,7 @@ public class AgencyServiceImpl implements AgencyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<EvolutionAgencyVO> getAgencyList() {
|
|
|
+ public List<EvaluationAgencyVO> getAgencyList() {
|
|
|
return mediator.renderAgencyList();
|
|
|
}
|
|
|
|