1.## map的原型由list而来
第一步得到;List
List<DepartmentPersonVO> personList = organizationFeignClient.getPersonByIds(Lists.newArrayList(personIds)).getData();
构建方法一:选取对象中的某一元素和对象本身形成Map
Map<Integer, DepartmentPersonVO> personMap = personList.stream().collect(Collectors.toMap(DepartmentPersonVO::getPersonId,
Function.identity()));
java 方法一的使用:
personMap.get(question.getSubmitter()).getPersonName()
构建方法二:选取list集合中的两列构成Map
Map<Integer, String> templateNameById = questionTemplateDao.listByIds(templateIds).stream()
.collect(Collectors.toMap(QuestionTemplate::getId, QuestionTemplate::getName));
java 方法二的使用:
templateNameById.get(question.getQuestionTemplateId()))
.projectName(question.getIsUnit()