文档库--系统消息
This commit is contained in:
+57
-24
@@ -1,11 +1,11 @@
|
||||
package com.jero.modules.system.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
@@ -13,6 +13,9 @@ import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.system.entity.SysAnnouncementSend;
|
||||
import com.jero.modules.system.model.AnnouncementSendModel;
|
||||
import com.jero.modules.system.service.ISysAnnouncementSendService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -23,14 +26,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
@@ -39,13 +39,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* @Date: 2019-02-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
|
||||
@Api(tags="消息")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysAnnouncementSend")
|
||||
@Slf4j
|
||||
public class SysAnnouncementSendController {
|
||||
@Autowired
|
||||
private ISysAnnouncementSendService sysAnnouncementSendService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param sysAnnouncementSend
|
||||
@@ -81,7 +83,7 @@ public class SysAnnouncementSendController {
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param sysAnnouncementSend
|
||||
@@ -99,7 +101,7 @@ public class SysAnnouncementSendController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param sysAnnouncementSend
|
||||
@@ -118,10 +120,10 @@ public class SysAnnouncementSendController {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
@@ -139,10 +141,10 @@ public class SysAnnouncementSendController {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
@@ -159,7 +161,7 @@ public class SysAnnouncementSendController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
@@ -177,7 +179,7 @@ public class SysAnnouncementSendController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:更新用户系统消息阅读状态
|
||||
* @param json
|
||||
@@ -198,7 +200,7 @@ public class SysAnnouncementSendController {
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:获取我的消息
|
||||
* @return
|
||||
@@ -239,4 +241,35 @@ public class SysAnnouncementSendController {
|
||||
result.setMessage("全部已读");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:标记已读
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/read")
|
||||
public Result<SysAnnouncementSend> read(String ids) {
|
||||
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
|
||||
List<SysAnnouncementSend> list = new ArrayList<>();
|
||||
for (String id : ids.split(",")) {
|
||||
SysAnnouncementSend sysAnnouncementSend = new SysAnnouncementSend();
|
||||
sysAnnouncementSend.setId(id);
|
||||
sysAnnouncementSend.setReadFlag("1");
|
||||
list.add(sysAnnouncementSend);
|
||||
}
|
||||
sysAnnouncementSendService.updateBatchById(list);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("标记已读");
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* @功能:查询所有的未读消息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getMessageUnreadList")
|
||||
public Result<?> getMessageUnreadList() {
|
||||
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
|
||||
List<AnnouncementSendModel> messageUnreadList = sysAnnouncementSendService.getMessageUnreadList();
|
||||
result.OK(messageUnreadList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -38,6 +38,11 @@ public class SysAnnouncement implements Serializable {
|
||||
*/
|
||||
@Excel(name = "内容", width = 30)
|
||||
private java.lang.String msgContent;
|
||||
|
||||
/**
|
||||
* 详细内容
|
||||
*/
|
||||
private java.lang.String msgContentInfo;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@@ -63,7 +68,7 @@ public class SysAnnouncement implements Serializable {
|
||||
@Excel(name = "优先级", width = 15, dicCode = "priority")
|
||||
@Dict(dicCode = "priority")
|
||||
private java.lang.String priority;
|
||||
|
||||
|
||||
/**
|
||||
* 消息类型1:通知公告2:系统消息
|
||||
*/
|
||||
@@ -144,4 +149,8 @@ public class SysAnnouncement implements Serializable {
|
||||
* 摘要
|
||||
*/
|
||||
private java.lang.String msgAbstract;
|
||||
/**
|
||||
* 文档id
|
||||
*/
|
||||
private java.lang.String documentId;
|
||||
}
|
||||
|
||||
+4
-2
@@ -22,10 +22,12 @@ public interface SysAnnouncementSendMapper extends BaseMapper<SysAnnouncementSen
|
||||
/**
|
||||
* @功能:获取我的消息
|
||||
* @param announcementSendModel
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
public List<AnnouncementSendModel> getMyAnnouncementSendList(Page<AnnouncementSendModel> page,@Param("announcementSendModel") AnnouncementSendModel announcementSendModel);
|
||||
|
||||
public List<AnnouncementSendModel> getMessageUnreadList(@Param("userId") String userId);
|
||||
|
||||
}
|
||||
|
||||
+11
-5
@@ -27,6 +27,12 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
public SysUser getUserByName(@Param("username") String username);
|
||||
/**
|
||||
* 通过用户账号查询用户信息(批量)
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
public List<SysUser> getUserListByNames(@Param("usernames") String usernames);
|
||||
|
||||
/**
|
||||
* 根据部门Id查询用户信息
|
||||
@@ -58,22 +64,22 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserByRoleId(Page page, @Param("roleId") String roleId, @Param("username") String username);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名设置部门ID
|
||||
* @param username
|
||||
* @param departId
|
||||
*/
|
||||
void updateUserDepart(@Param("username") String username,@Param("orgCode") String orgCode);
|
||||
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public SysUser getUserByPhone(@Param("phone") String phone);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据邮箱查询用户信息
|
||||
* @param email
|
||||
@@ -132,7 +138,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
/** 更新空字符串为null【此写法有sql注入风险,禁止随便用】 */
|
||||
int updateNullByEmptyString(@Param("fieldName") String fieldName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门Ids,查询部门下用户信息
|
||||
* @param departIds
|
||||
|
||||
+9
-7
@@ -6,6 +6,7 @@
|
||||
<result column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="titile" property="titile" jdbcType="VARCHAR"/>
|
||||
<result column="msg_content" property="msgContent" jdbcType="VARCHAR"/>
|
||||
<result column="msg_content_info" property="msgContentInfo" jdbcType="VARCHAR"/>
|
||||
<result column="start_time" property="startTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="end_time" property="endTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="sender" property="sender" jdbcType="VARCHAR"/>
|
||||
@@ -25,16 +26,17 @@
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
<result column="document_id" property="documentId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
|
||||
<select id="querySysCementListByUserId" parameterType="String" resultMap="SysAnnouncement">
|
||||
select * from sys_announcement
|
||||
where send_status = '1'
|
||||
and del_flag = '0'
|
||||
and msg_category = #{msgCategory}
|
||||
select * from sys_announcement
|
||||
where send_status = '1'
|
||||
and del_flag = '0'
|
||||
and msg_category = #{msgCategory}
|
||||
and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = '0')
|
||||
order by create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
+36
-8
@@ -1,13 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.system.mapper.SysAnnouncementSendMapper">
|
||||
|
||||
|
||||
<resultMap id="AnnouncementSendModel" type="com.jero.modules.system.model.AnnouncementSendModel" >
|
||||
<result column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="annt_id" property="anntId" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userId" jdbcType="VARCHAR"/>
|
||||
<result column="titile" property="titile" jdbcType="VARCHAR"/>
|
||||
<result column="msg_content" property="msgContent" jdbcType="VARCHAR"/>
|
||||
<result column="msg_content_info" property="msgContentInfo" jdbcType="VARCHAR"/>
|
||||
<result column="sender" property="sender" jdbcType="VARCHAR"/>
|
||||
<result column="priority" property="priority" jdbcType="VARCHAR"/>
|
||||
<result column="msg_category" property="msgCategory" jdbcType="VARCHAR"/>
|
||||
@@ -15,13 +16,14 @@
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
<result column="document_id" property="documentId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="queryByUserId" parameterType="String" resultType="String">
|
||||
select sas.annt_id from sys_announcement_send sas
|
||||
select sas.annt_id from sys_announcement_send sas
|
||||
where sas.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getMyAnnouncementSendList" parameterType="Object" resultMap="AnnouncementSendModel">
|
||||
select
|
||||
sas.id,
|
||||
@@ -30,6 +32,7 @@
|
||||
sas.read_flag,
|
||||
sa.titile as titile,
|
||||
sa.msg_content as msg_content,
|
||||
sa.msg_content_info as msg_content_info,
|
||||
sa.sender as sender,
|
||||
sa.priority as priority,
|
||||
sa.msg_category,
|
||||
@@ -37,11 +40,11 @@
|
||||
sa.bus_id as bus_id,
|
||||
sa.open_type as open_type,
|
||||
sa.open_page as open_page,
|
||||
sa.msg_abstract
|
||||
sa.msg_abstract,
|
||||
sa.document_id as document_id
|
||||
from sys_announcement_send sas
|
||||
left join sys_announcement sa ON sas.annt_id = sa.id
|
||||
where sa.send_status = '1'
|
||||
and sa.del_flag = '0'
|
||||
where sa.del_flag = '0'
|
||||
and sas.user_id = #{announcementSendModel.userId}
|
||||
<if test="announcementSendModel.titile !=null and announcementSendModel.titile != ''">
|
||||
and sa.titile LIKE concat(concat('%',#{announcementSendModel.titile}),'%')
|
||||
@@ -63,5 +66,30 @@
|
||||
</if>
|
||||
order by sas.read_flag,sa.send_time desc
|
||||
</select>
|
||||
<select id="getMessageUnreadList" parameterType="Object" resultMap="AnnouncementSendModel">
|
||||
select
|
||||
sas.id,
|
||||
sas.annt_id,
|
||||
sas.user_id,
|
||||
sas.read_flag,
|
||||
sa.titile as titile,
|
||||
sa.msg_content as msg_content,
|
||||
sa.msg_content_info as msg_content_info,
|
||||
sa.sender as sender,
|
||||
sa.priority as priority,
|
||||
sa.msg_category,
|
||||
sa.send_time as send_time,
|
||||
sa.bus_id as bus_id,
|
||||
sa.open_type as open_type,
|
||||
sa.open_page as open_page,
|
||||
sa.msg_abstract,
|
||||
sa.document_id as document_id
|
||||
from sys_announcement_send sas
|
||||
left join sys_announcement sa ON sas.annt_id = sa.id
|
||||
where sa.del_flag = '0'
|
||||
and sas.read_flag = '0'
|
||||
and sas.user_id = #{userId}
|
||||
order by sas.read_flag,sa.send_time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
+12
-3
@@ -6,6 +6,15 @@
|
||||
<select id="getUserByName" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user where username = #{username} and del_flag = 0
|
||||
</select>
|
||||
<!-- 根据用户名查询(批量) -->
|
||||
<select id="getUserListByNames" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user
|
||||
where username in
|
||||
<foreach collection="usernames.split(',')" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据部门Id查询 -->
|
||||
<select id="getUserByDepId" resultType="com.jero.modules.system.entity.SysUser">
|
||||
@@ -45,7 +54,7 @@
|
||||
and username = #{username}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 修改用户部门code -->
|
||||
<update id="updateUserDepart">
|
||||
UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
|
||||
@@ -55,7 +64,7 @@
|
||||
<select id="getUserByPhone" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user where phone = #{phone} and del_flag = 0
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据邮箱查询用户信息 -->
|
||||
<select id="getUserByEmail" resultType="com.jero.modules.system.entity.SysUser">
|
||||
select * from sys_user where email = #{email} and del_flag = 0
|
||||
@@ -161,4 +170,4 @@
|
||||
and username != #{username}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
+7
-1
@@ -20,7 +20,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class AnnouncementSendModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private java.lang.String id;
|
||||
@@ -32,6 +32,8 @@ public class AnnouncementSendModel implements Serializable {
|
||||
private java.lang.String titile;
|
||||
/**内容*/
|
||||
private java.lang.String msgContent;
|
||||
/**详细内容*/
|
||||
private java.lang.String msgContentInfo;
|
||||
/**发布人*/
|
||||
private java.lang.String sender;
|
||||
/**优先级(L低,M中,H高)*/
|
||||
@@ -76,5 +78,9 @@ public class AnnouncementSendModel implements Serializable {
|
||||
* 摘要
|
||||
*/
|
||||
private java.lang.String msgAbstract;
|
||||
/**
|
||||
* 文档id
|
||||
*/
|
||||
private java.lang.String documentId;
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -17,7 +17,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface ISysAnnouncementSendService extends IService<SysAnnouncementSend> {
|
||||
|
||||
public List<String> queryByUserId(String userId);
|
||||
|
||||
|
||||
/**
|
||||
* @功能:获取我的消息
|
||||
* @param announcementSendModel
|
||||
@@ -25,4 +25,6 @@ public interface ISysAnnouncementSendService extends IService<SysAnnouncementSen
|
||||
*/
|
||||
public Page<AnnouncementSendModel> getMyAnnouncementSendPage(Page<AnnouncementSendModel> page,AnnouncementSendModel announcementSendModel);
|
||||
|
||||
List<AnnouncementSendModel> getMessageUnreadList();
|
||||
|
||||
}
|
||||
|
||||
+9
-1
@@ -4,10 +4,12 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.system.entity.SysAnnouncementSend;
|
||||
import com.jero.modules.system.mapper.SysAnnouncementSendMapper;
|
||||
import com.jero.modules.system.model.AnnouncementSendModel;
|
||||
import com.jero.modules.system.service.ISysAnnouncementSendService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -24,7 +26,7 @@ public class SysAnnouncementSendServiceImpl extends ServiceImpl<SysAnnouncementS
|
||||
|
||||
@Resource
|
||||
private SysAnnouncementSendMapper sysAnnouncementSendMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> queryByUserId(String userId) {
|
||||
return sysAnnouncementSendMapper.queryByUserId(userId);
|
||||
@@ -36,4 +38,10 @@ public class SysAnnouncementSendServiceImpl extends ServiceImpl<SysAnnouncementS
|
||||
return page.setRecords(sysAnnouncementSendMapper.getMyAnnouncementSendList(page, announcementSendModel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnnouncementSendModel> getMessageUnreadList() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
return sysAnnouncementSendMapper.getMessageUnreadList(sysUser.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,10 +32,10 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
|
||||
|
||||
@Resource
|
||||
private SysAnnouncementMapper sysAnnouncementMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysAnnouncementSendMapper sysAnnouncementSendMapper;
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void saveAnnouncement(SysAnnouncement sysAnnouncement) {
|
||||
@@ -46,7 +46,7 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
|
||||
sysAnnouncementMapper.insert(sysAnnouncement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = sysAnnouncement.getUserIds();
|
||||
String[] userIds = userId.substring(0, (userId.length()-1)).split(",");
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = sysAnnouncement.getId();
|
||||
Date refDate = new Date();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
@@ -59,7 +59,7 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:编辑消息信息
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user