UserSysMsgNotifyServiceImpl.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.cyksj.service.user.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.cyksj.common.constant.Constant;
  5. import com.cyksj.mapper.UserSysMsgNotifyMapper;
  6. import com.cyksj.model.entity.GroupsRelation;
  7. import com.cyksj.model.entity.UserSysMsgNotify;
  8. import com.cyksj.model.manage.views.GroupsRelationView;
  9. import com.cyksj.service.user.UserSysMsgNotifyService;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.stereotype.Service;
  13. import java.util.HashSet;
  14. import java.util.List;
  15. import java.util.Set;
  16. import java.util.stream.Collectors;
  17. /**
  18. * 项目名: yhlxj2
  19. * 文件名: UserSysMsgNotifyServiceImpl
  20. * 创建者: JavaZou
  21. * 创建时间:2024/2/4 16:03
  22. */
  23. @Service
  24. @RequiredArgsConstructor
  25. @Slf4j
  26. public class UserSysMsgNotifyServiceImpl extends ServiceImpl<UserSysMsgNotifyMapper, UserSysMsgNotify> implements UserSysMsgNotifyService {
  27. private final UserSysMsgNotifyMapper userSysMsgNotifyMapper;
  28. @Override
  29. public void recordUserAccountUpdateSysMsg(Long goodsId, Long skuId, List<GroupsRelationView> relations, String account, String title) {
  30. String sysMsg = String.format(Constant.ACCOUNT_PWD_UPDATE_SYS_MSG_NOTIFY, title);
  31. Set<Long> userSet = new HashSet<>();
  32. List<GroupsRelationView> collect = relations.stream().filter(e -> {
  33. if (userSet.contains(e.getUserId())) {
  34. return false;
  35. }
  36. userSet.add(e.getUserId());
  37. return true;
  38. }).collect(Collectors.toList());
  39. if (CollUtil.isNotEmpty(collect)) {
  40. userSysMsgNotifyMapper.recordUserAccountUpdateSysMsg(goodsId, skuId, collect, account, sysMsg);
  41. }
  42. }
  43. @Override
  44. public void recordUserAccountSetSysMsg(Long goodsId, Long skuId, List<GroupsRelation> relations, String account, String title) {
  45. String sysMsg = String.format(Constant.ACCOUNT_SET_SYS_MSG_NOTIFY, title);
  46. Set<Long> userSet = new HashSet<>();
  47. List<GroupsRelation> collect = relations.stream().filter(e -> {
  48. if (userSet.contains(e.getUserId())) {
  49. return false;
  50. }
  51. userSet.add(e.getUserId());
  52. return true;
  53. }).collect(Collectors.toList());
  54. if (CollUtil.isNotEmpty(collect)) {
  55. userSysMsgNotifyMapper.recordUserAccountSetSysMsg(goodsId, skuId, collect, account, sysMsg);
  56. }
  57. }
  58. }