public class ServiceImpl{
public Map<String,List<Dto>> getInfoByCode(Param param) {
List<Dto> allDtos = this.mapper.getInfoByCode(param);
return allDtos.stream().collect(Collectors.groupingBy(Dto::getCode));
}
class Dto{
String code;
String name;
String id;
//getter、setter方法
}
}
code作为key值,分组list,封装到map返回。 J8版本真的强大!