基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)

 更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

1、下面提供给前端待办提醒消息的接口SysNoticeController,增加如下:

 /**
	 * 补充用户数据,并返回系统消息
	 * @return
	 */
    @Log(title = "系统消息")
    @GetMapping("/listByUser")
    public R> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
    	LoginUser loginUser = commonService.getLoginUser();
		Long userId = loginUser.getUserId();
		// 1.将系统消息补充到用户通告阅读标记表中
		LambdaQueryWrapper querySaWrapper = new LambdaQueryWrapper();
		querySaWrapper.eq(SysNotice::getMsgType,Constants.MSG_TYPE_ALL); // 全部人员
		querySaWrapper.eq(SysNotice::getStatus,Constants.CLOSE_FLAG_0.toString());  // 未关闭
		querySaWrapper.eq(SysNotice::getSendStatus, Constants.HAS_SEND); //已发布
		//querySaWrapper.ge(SysNotice::getEndTime, loginUser.getCreateTime()); //新注册用户不看结束通知
		querySaWrapper.notInSql(SysNotice::getNoticeId,"select notice_id from sys_notice_send where user_id='"+userId+"'");
		List notices = noticeService.list(querySaWrapper);
		if(notices.size()>0) {
			for(int i=0;i query = new LambdaQueryWrapper<>();
				query.eq(SysNoticeSend::getNoticeId,notices.get(i).getNoticeId());
				query.eq(SysNoticeSend::getUserId,userId);
				SysNoticeSend one = noticeSendService.getOne(query);
				if(null==one){
					SysNoticeSend noticeSend = new SysNoticeSend();
					noticeSend.setNoticeId(notices.get(i).getNoticeId());
					noticeSend.setUserId(userId);
					noticeSend.setReadFlag(Constants.NO_READ_FLAG);
					noticeSendService.save(noticeSend);
				}
			}
		}
		// 2.查询用户未读的系统消息
		Page anntMsgList = new Page(0, pageSize);
		anntMsgList = noticeService.querySysNoticePageByUserId(anntMsgList,userId,"1");//通知公告消息
		Page sysMsgList = new Page(0, pageSize);
		sysMsgList = noticeService.querySysNoticePageByUserId(sysMsgList,userId,"2");//系统消息
		Page todealMsgList = new Page(0, pageSize);
		todealMsgList = noticeService.querySysNoticePageByUserId(todealMsgList,userId,"3");//待办消息
		Map sysMsgMap = new HashMap();
		sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
		sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
		sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
		sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
		sysMsgMap.put("todealMsgList", todealMsgList.getRecords());
		sysMsgMap.put("todealMsgTotal", todealMsgList.getTotal());
		return R.ok(sysMsgMap);
    }

2、其中这里用到了querySysNoticePageByUserId方法

@Override
	public Page querySysNoticePageByUserId(Page page, Long userId, String msgCategory) {
		if (page.getSize() == -1) {
			return page.setRecords(baseMapper.querySysNoticeListByUserId(null, userId.toString(), msgCategory));
		} else {
			return page.setRecords(baseMapper.querySysNoticeListByUserId(page, userId.toString(), msgCategory));
		}
	}

3、上面又用到了sql 在SysNoticeMapper.xml里





    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
    

至此,后端的代码基本上就这些了,下一节开始讲一下前端。

你可能感兴趣的:(ruoyi-nbcio,若依,flowable,ruoyi-nbcio,flowable,若依)