|
@@ -5,9 +5,6 @@ import com.mooctest.crowd.domain.dao.ResidentAgencyDao;
|
|
|
import com.mooctest.crowd.domain.dao.TaskToUserDao;
|
|
|
import com.mooctest.crowd.domain.dao.UserDao;
|
|
|
import com.mooctest.crowd.domain.model.EvaluationAgencyPO;
|
|
|
-import com.mooctest.crowd.domain.model.RankCountInfo;
|
|
|
-import com.mooctest.crowd.domain.model.ResidentAgencyPO;
|
|
|
-import com.mooctest.crowd.domain.model.UserPO;
|
|
|
import com.mooctest.crowd.site.data.vo.ResidentAgencyVO;
|
|
|
import com.mooctest.crowd.site.service.ResidentAgencyService;
|
|
|
import com.mooctest.crowd.site.util.DataUtils;
|
|
@@ -17,9 +14,8 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author:xx
|
|
@@ -40,30 +36,22 @@ public class ResidentServiceImpl implements ResidentAgencyService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Page<ResidentAgencyVO> findAll(Pageable pageable) {
|
|
|
- List<ResidentAgencyVO> list = new ArrayList<>();
|
|
|
- List<RankCountInfo> totalCountOfUser = taskToUserDao.findTotalCountOfUser();
|
|
|
- long ids[] = new long[totalCountOfUser.size()];
|
|
|
- List<ResidentAgencyPO> residentAgencyPOS = residentAgencyDao.findAll();
|
|
|
- //获取品牌机构的用户id
|
|
|
- long resagency[] = new long[residentAgencyPOS.size()];
|
|
|
- for (int i = 0; i < residentAgencyPOS.size(); i++) {
|
|
|
+ public Page<ResidentAgencyVO> findAll(Pageable pageable, String keyword) {
|
|
|
+ List<ResidentAgencyVO> residentAgencyVOList = residentAgencyDao.findAll().stream().map(residentAgencyPO -> {
|
|
|
ResidentAgencyVO residentAgencyVO = new ResidentAgencyVO();
|
|
|
- Optional<UserPO> userPO = userDao.findById(residentAgencyPOS.get(i).getUserId());
|
|
|
- resagency[i] = residentAgencyPOS.get(i).getUserId();
|
|
|
- EvaluationAgencyPO evaluationAgencyPO = agencyDao.findByUserId(resagency[i]);
|
|
|
+ EvaluationAgencyPO evaluationAgencyPO = agencyDao.findByUserId(residentAgencyPO.getUserId());
|
|
|
residentAgencyVO.setName(evaluationAgencyPO.getEvaluationAgencyName());
|
|
|
residentAgencyVO.setAgencyPhoto(evaluationAgencyPO.getAgencyPhoto());
|
|
|
- residentAgencyVO.setTaskCount(totalCountOfUser.get(i).getCount());
|
|
|
residentAgencyVO.setAddress(evaluationAgencyPO.getAddress());
|
|
|
- residentAgencyVO.setAgencyId(residentAgencyPOS.get(i).getAgencyId());
|
|
|
- residentAgencyVO.setId(residentAgencyPOS.get(i).getId());
|
|
|
- residentAgencyVO.setUserId(residentAgencyPOS.get(i).getUserId());
|
|
|
- list.add(residentAgencyVO);
|
|
|
+ residentAgencyVO.setAgencyId(evaluationAgencyPO.getId());
|
|
|
+ residentAgencyVO.setId(residentAgencyPO.getId());
|
|
|
+ residentAgencyVO.setUserId(residentAgencyPO.getUserId());
|
|
|
+ return residentAgencyVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(keyword != null && keyword != ""){
|
|
|
+ residentAgencyVOList = residentAgencyVOList.stream().filter(residentAgencyVO -> residentAgencyVO.getName().contains(keyword)).collect(Collectors.toList());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- Page<ResidentAgencyVO> page = DataUtils.listToPage(list, pageable);
|
|
|
+ Page<ResidentAgencyVO> page = DataUtils.listToPage(residentAgencyVOList, pageable);
|
|
|
return page;
|
|
|
}
|
|
|
}
|