| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
| | | import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.mapper.SysUserMapper;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.context.annotation.Lazy;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeByRoles(final String title, String message, List<String> needPushRoles,
|
| | | final String jumpPath) {
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | if (StrUtil.isBlank(message) || CollectionUtils.isEmpty(needPushRoles)) {
|
| | | return;
|
| | | }
|
| | | List<String> rolesWithAdmin = new ArrayList<>(needPushRoles);
|
| | | rolesWithAdmin.add("管理员");
|
| | | List<SysNotice> collect = rolesWithAdmin.stream()
|
| | | .flatMap(it -> userMapper.getUserByRole(it).stream())
|
| | | .map(it -> convertSysNotice(title, message, it, jumpPath, userId))
|
| | | .collect(Collectors.toList());
|
| | | sysNoticeService.insertBatch(collect);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeByPerms(String title, String message, List<String> needPerms,
|
| | | String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | if (StrUtil.isBlank(message) || CollectionUtils.isEmpty(needPerms)) {
|
| | | return;
|
| | | }
|
| | | List<SysNotice> collect = userMapper.getUserByPerms(needPerms).stream().map(it -> convertSysNotice(title, message, it, jumpPath, userId)).collect(Collectors.toList());
|
| | | sysNoticeService.insertBatch(collect);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeByUser(String title, String message, Long consigneeId,
|
| | | public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, Long tenantId,
|
| | | String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | SysNotice sysNotice = convertSysNotice(title, message, consigneeId, jumpPath, userId);
|
| | | sysNoticeService.save(sysNotice);
|
| | | List<SysNotice> sysNotices = consigneeId.stream().map(it -> convertSysNotice(title, message, it,tenantId, jumpPath, userId)).collect(Collectors.toList());
|
| | | sysNoticeService.saveBatch(sysNotices);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void simpleNoticeAll(String title, String message, String jumpPath) {
|
| | | public void simpleNoticeAll(String title, String message, Long tenantId,String jumpPath) {
|
| | | Long userId = SecurityUtils.getLoginUser().getUserId();
|
| | | List<SysNotice> collect = userMapper.selectList(null).stream().map(it -> convertSysNotice(title, message, it.getUserId(), jumpPath, userId)).collect(Collectors.toList());
|
| | | List<SysUser> sysUsers = userMapper.selectList(Wrappers.<SysUser>lambdaQuery()
|
| | | .eq(SysUser::getStatus, "0")
|
| | | .eq(SysUser::getTenantId, tenantId));
|
| | | List<SysNotice> collect = sysUsers.stream().map(it -> convertSysNotice(title, message, it.getUserId(),tenantId, jumpPath, userId)).collect(Collectors.toList());
|
| | | sysNoticeService.saveBatch(collect);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void insertBatch(List<SysNotice> noticesList) {
|
| | | if(CollectionUtils.isEmpty(noticesList)){
|
| | | return;
|
| | | }
|
| | | // 排除掉自己
|
| | | Long userId = SecurityUtils.getUserId();
|
| | | List<SysNotice> noticesListNew = noticesList.stream().filter(Objects::nonNull).filter(it -> !Objects.equals(it.getConsigneeId(), userId)).collect(Collectors.toList());
|
| | | sysNoticeService.saveBatch(noticesListNew);
|
| | |
|
| | | }
|
| | |
|
| | | private SysNotice convertSysNotice(String title,String message,Long consigneeId,String jumpPath,Long currentUserId) {
|
| | | private SysNotice convertSysNotice(String title,String message,Long consigneeId, Long tenantId,String jumpPath,Long currentUserId) {
|
| | | SysNotice sysNotice = new SysNotice();
|
| | | sysNotice.setNoticeType("1");
|
| | | sysNotice.setNoticeTitle(title);//标题
|
| | |
| | | sysNotice.setConsigneeId(consigneeId);
|
| | | sysNotice.setSenderId(currentUserId);
|
| | | sysNotice.setJumpPath(jumpPath);
|
| | | sysNotice.setTenantId(tenantId);
|
| | | return sysNotice;
|
| | | }
|
| | | }
|