JAVA
司天真
这个作者很懒,什么都没留下…
展开
-
一个用户有多个标签
两次遍历 userId 重复的 把它们转成 <userId,List > 形式 private Map getmA(List<UserTagsDTO> userTagsDTOS) { HashMap<Long, Object> HashMap = new HashMap<>(); for (UserTagsDTO userTagsDTO : userTagsDTOS) { List<Tag原创 2021-11-08 11:19:11 · 196 阅读 · 0 评论 -
取list中的所有id
把查询出来的用户的userId转成一个集合 List<UserTagsDTO> userTagsDtos = tagService.selectTagByContent(mobile); List<Long> userIds = userTagsDtos.stream().map(UserTagsDTO::getUserId).collect(Collectors.toList());...原创 2021-11-08 11:14:46 · 4477 阅读 · 0 评论 -
JAVA 查询的数据转成key value 形式
话不多少,上代码下面则是套餐名称可能是多个则进行逗号进行连接 //加载所有的套餐 List<ProductCombo> allCombos = productComboService.selectProductComboList(new ProductCombo()); Map<Long, String> commboMap = allCombos.stream().collect(Collectors.toMap(ProductCombo::原创 2021-11-08 11:05:10 · 575 阅读 · 0 评论 -
2021-09-24
提取字符串中的手机号由于现在手机号样式过多,提取手机号用正则要判断更多一些的字符但是11位数字永远改变不掉下面就是代码: public static String getPhoneNum(String str) { String regex = "[\\d]{11}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str);原创 2021-10-18 10:17:07 · 70 阅读 · 0 评论