当前位置:首页 > 编程笔记 > 正文
已解决

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

来自网友在路上 165865提问 提问时间:2023-09-24 02:52:04阅读次数: 65

最佳答案 问答题库658位专家为你答疑解惑

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

gitee源代码地址

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

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

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

 /*** 补充用户数据,并返回系统消息* @return*/@Log(title = "系统消息")@GetMapping("/listByUser")public R<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {LoginUser loginUser = commonService.getLoginUser();Long userId = loginUser.getUserId();// 1.将系统消息补充到用户通告阅读标记表中LambdaQueryWrapper<SysNotice> querySaWrapper = new LambdaQueryWrapper<SysNotice>();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<SysNotice> notices = noticeService.list(querySaWrapper);if(notices.size()>0) {for(int i=0;i<notices.size();i++) {	//因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑LambdaQueryWrapper<SysNoticeSend> 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<SysNotice> anntMsgList = new Page<SysNotice>(0, pageSize);anntMsgList = noticeService.querySysNoticePageByUserId(anntMsgList,userId,"1");//通知公告消息Page<SysNotice> sysMsgList = new Page<SysNotice>(0, pageSize);sysMsgList = noticeService.querySysNoticePageByUserId(sysMsgList,userId,"2");//系统消息Page<SysNotice> todealMsgList = new Page<SysNotice>(0, pageSize);todealMsgList = noticeService.querySysNoticePageByUserId(todealMsgList,userId,"3");//待办消息Map<String,Object> sysMsgMap = new HashMap<String, Object>();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方法

@Overridepublic Page<SysNotice> querySysNoticePageByUserId(Page<SysNotice> 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里

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper"><resultMap type="com.ruoyi.system.domain.SysNotice" id="SysNoticeResult"><result property="noticeId" column="notice_id"/><result property="noticeTitle" column="notice_title"/><result property="noticeType" column="notice_type"/><result property="noticeContent" column="notice_content"/><result property="status" column="status"/><result property="sender" column="sender"/><result property="priority" column="priority"/><result property="msgType" column="msg_type"/><result property="sendStatus" column="send_status"/><result property="sendTime" column="send_time"/><result property="cancelTime" column="cancel_time"/><result property="createBy" column="create_by"/><result property="createTime" column="create_time"/><result property="updateBy" column="update_by"/><result property="updateTime" column="update_time"/><result property="remark" column="remark"/></resultMap><select id="querySysNoticeListByUserId" parameterType="String"  resultMap="SysNoticeResult">select * from sys_noticewhere send_status = '1' and status = '0' and notice_type = #{msgCategory} and notice_id IN ( select notice_id from sys_notice_send where user_id = CAST(#{userId} AS SIGNED INTEGER) and read_flag = '0')order by create_time DESC</select></mapper>

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

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"基于若依ruoyi-nbcio增加flowable流程待办消息的提醒,并提供右上角的红字数字提醒(五)":http://eshow365.cn/6-12475-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!