当前位置: 首页 > news >正文

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

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>

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

http://www.lryc.cn/news/173255.html

相关文章:

  • hive数据初始化
  • React+Node——next.js 构建前后端项目
  • CRM系统主要包括哪些功能?
  • Nginx location 精准匹配URL = /
  • 使用JAXB将Java对象转xml
  • Atlas 200 DK开发板问题总结
  • uniapp——实现二维码生成+保存二维码图片——基础积累
  • 零基础学前端(六)重点讲解 JavaScript
  • 数据库问题记录(粗略版)oracle、mysql等主流数据库通用
  • ORACLE多列中取出数据最大的一条
  • Xamarin.Android实现App内版本更新
  • 运维工程师面经
  • stm32之智能垃圾桶实战
  • 【C++面向对象侯捷下】2.转换函数 | 3.non-explicit-one-argument ctor
  • UOS Deepin Ubuntu Linux 开启 ssh 远程登录
  • Postman应用——接口请求和响应(Get和Post请求)
  • Linux查看哪些进程占用的系统 buffer/cache 较高 (hcache,lsof)命令
  • (Vue2)自定义创建项目、ESLint、Vuex
  • LLaMa
  • API(九)基于协程的并发编程SDK
  • JavaWeb 学习笔记 7:Filter
  • 【AI视野·今日Robot 机器人论文速览 第三十五期】Mon, 18 Sep 2023
  • Elasticsearch 在bool查询中使用分词器
  • 在Python中创建相关系数矩阵的6种方法
  • 物联网、工业大数据平台 TDengine 与苍穹地理信息平台完成兼容互认证
  • this.$nextTick()的使用场景
  • idea(第一次)启动项目,端口变成了8080
  • brpc 学习(一)M1 MacOS构建方法
  • Python 与 Qt c++ 程序共享内存,传递图片
  • 【2023年中国研究生数学建模竞赛华为杯】E题 出血性脑卒中临床智能诊疗建模 问题分析、数学模型及代码实现