消息发送指定用户 配置管理功能
This commit is contained in:
parent
687c5ac55d
commit
62ebf974a4
|
@ -77,8 +77,8 @@ public class SysNoticeController extends BaseController
|
||||||
notice.setCreateBy(getUsername());
|
notice.setCreateBy(getUsername());
|
||||||
noticeService.insertNotice(notice);
|
noticeService.insertNotice(notice);
|
||||||
//推送消息插入中间表
|
//推送消息插入中间表
|
||||||
Long userId = getLoginUser().getUserId();//当前登陆者
|
String userName = getLoginUser().getUsername();//当前登陆者
|
||||||
insertNoticeUser(userId,notice,noticeService,null);
|
insertNoticeUser(userName,notice,noticeService,null);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ public class SysNoticeController extends BaseController
|
||||||
@GetMapping("/navbarNoticelist")
|
@GetMapping("/navbarNoticelist")
|
||||||
public Map<String, List<SysNotice>> navbarNoticelist()
|
public Map<String, List<SysNotice>> navbarNoticelist()
|
||||||
{
|
{
|
||||||
Long userId = getLoginUser().getUserId();//当前登陆者
|
String userName = getLoginUser().getUsername();//当前登陆者
|
||||||
List<SysNotice> list = noticeService.navbarNoticelist(userId);
|
List<SysNotice> list = noticeService.navbarNoticelist(userName);
|
||||||
Map<String, List<SysNotice>> groupedByNoticeType = list.stream()
|
Map<String, List<SysNotice>> groupedByNoticeType = list.stream()
|
||||||
.collect(Collectors.groupingBy(SysNotice::getNoticeType));
|
.collect(Collectors.groupingBy(SysNotice::getNoticeType));
|
||||||
for(String key:groupedByNoticeType.keySet()){
|
for(String key:groupedByNoticeType.keySet()){
|
||||||
|
@ -133,10 +133,14 @@ public class SysNoticeController extends BaseController
|
||||||
public AjaxResult getNavbarNoticeInfo(@PathVariable Long noticeId)
|
public AjaxResult getNavbarNoticeInfo(@PathVariable Long noticeId)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
//更新消息表 isRead字段 设置 为 1-已读
|
String userName = getLoginUser().getUsername();//当前登陆者
|
||||||
SysNotice sysNotice = noticeService.selectNoticeById(noticeId);
|
//更新sys_user_notice推送消息插入中间表 isRead字段 设置 为 1-已读
|
||||||
sysNotice.setIsRead("1");
|
SysNoticeUser sysNoticeUser = new SysNoticeUser();
|
||||||
noticeService.updateNotice(sysNotice);
|
sysNoticeUser.setNoticeId(noticeId);
|
||||||
|
sysNoticeUser.setUserId(userName);
|
||||||
|
sysNoticeUser.setIsRead("1");
|
||||||
|
noticeService.updateSysNoticeUser(sysNoticeUser);
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
return error("系统异常");
|
return error("系统异常");
|
||||||
}
|
}
|
||||||
|
@ -145,11 +149,11 @@ public class SysNoticeController extends BaseController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送消息插入中间表
|
* 推送消息插入中间表
|
||||||
* @param userId 发送对象排除自身
|
* @param userName 发送对象排除自身
|
||||||
* @param notice 发送信息对象
|
* @param notice 发送信息对象
|
||||||
* @param noticeService 接口
|
* @param noticeService 接口
|
||||||
*/
|
*/
|
||||||
public static void insertNoticeUser(Long userId,SysNotice notice,ISysNoticeService noticeService,List<String> userIds) throws IOException {
|
public static void insertNoticeUser(String userName,SysNotice notice,ISysNoticeService noticeService,List<String> userNames) throws IOException {
|
||||||
List<SysNoticeUser> sysNoticeUsers = new ArrayList<SysNoticeUser>();
|
List<SysNoticeUser> sysNoticeUsers = new ArrayList<SysNoticeUser>();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
|
@ -163,11 +167,11 @@ public class SysNoticeController extends BaseController
|
||||||
SysNoticeUser sysNoticeUser = null;
|
SysNoticeUser sysNoticeUser = null;
|
||||||
CopyOnWriteArraySet<WebSocket> webSocketSet = WebSocket.getWebSocketSet();//获取在线用户
|
CopyOnWriteArraySet<WebSocket> webSocketSet = WebSocket.getWebSocketSet();//获取在线用户
|
||||||
for (WebSocket item : webSocketSet) {
|
for (WebSocket item : webSocketSet) {
|
||||||
String userid = item.sid;
|
String username = item.sid;
|
||||||
if(!userid.equals(String.valueOf(userId))){
|
if(!username.equals(userName)){
|
||||||
sysNoticeUser = new SysNoticeUser();
|
sysNoticeUser = new SysNoticeUser();
|
||||||
sysNoticeUser.setNoticeId(notice.getNoticeId());
|
sysNoticeUser.setNoticeId(notice.getNoticeId());
|
||||||
sysNoticeUser.setUserId(Long.valueOf(userid));
|
sysNoticeUser.setUserId(username);
|
||||||
sysNoticeUsers.add(sysNoticeUser);
|
sysNoticeUsers.add(sysNoticeUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,18 +179,18 @@ public class SysNoticeController extends BaseController
|
||||||
noticeService.insertNoticeUserBatch(sysNoticeUsers);
|
noticeService.insertNoticeUserBatch(sysNoticeUsers);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(userIds!=null&&userIds.size()>0){
|
if(userNames!=null&&userNames.size()>0){
|
||||||
for(String uid:userIds){
|
for(String names:userNames){
|
||||||
WebSocket.sendInfo(obj.toString(),uid);
|
WebSocket.sendInfo(obj.toString(),names);
|
||||||
}
|
}
|
||||||
SysNoticeUser sysNoticeUser = null;
|
SysNoticeUser sysNoticeUser = null;
|
||||||
CopyOnWriteArraySet<WebSocket> webSocketSet = WebSocket.getWebSocketSet();//获取在线用户
|
CopyOnWriteArraySet<WebSocket> webSocketSet = WebSocket.getWebSocketSet();//获取在线用户
|
||||||
for (WebSocket item : webSocketSet) {
|
for (WebSocket item : webSocketSet) {
|
||||||
String userid = item.sid;
|
String username = item.sid;
|
||||||
if(userIds.contains(userid)){
|
if(userNames.contains(username)){
|
||||||
sysNoticeUser = new SysNoticeUser();
|
sysNoticeUser = new SysNoticeUser();
|
||||||
sysNoticeUser.setNoticeId(notice.getNoticeId());
|
sysNoticeUser.setNoticeId(notice.getNoticeId());
|
||||||
sysNoticeUser.setUserId(Long.valueOf(userid));
|
sysNoticeUser.setUserId(username);
|
||||||
sysNoticeUsers.add(sysNoticeUser);
|
sysNoticeUsers.add(sysNoticeUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,4 +212,30 @@ public class SysNoticeController extends BaseController
|
||||||
List<NoticeUserSelect> list = noticeService.listNoticeEventUser(noticeUserSelect);
|
List<NoticeUserSelect> list = noticeService.listNoticeEventUser(noticeUserSelect);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveNoticeEventUser")
|
||||||
|
public AjaxResult saveNoticeEventUser(@RequestBody List<NoticeUserSelect> list)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
if(list!=null&&list.size()>0){
|
||||||
|
String noticeEventType = list.get(0).getNoticeEventType();
|
||||||
|
noticeService.deleteNoticeEventUserByType(noticeEventType);
|
||||||
|
noticeService.insertNoticeEventUserBatch(list);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
return error("系统异常");
|
||||||
|
}
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delNoticeEventUser")
|
||||||
|
public AjaxResult delNoticeEventUser(@RequestBody NoticeUserSelect noticeUserSelect)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
noticeService.deleteNoticeEventUser(noticeUserSelect);
|
||||||
|
}catch (Exception e){
|
||||||
|
return error("系统异常");
|
||||||
|
}
|
||||||
|
return success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,6 @@ public class SysNotice extends BaseEntity
|
||||||
/** 公告状态(0正常 1关闭) */
|
/** 公告状态(0正常 1关闭) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 公告是否已读(0未读 1已读) */
|
|
||||||
private String isRead;
|
|
||||||
|
|
||||||
public Long getNoticeId()
|
public Long getNoticeId()
|
||||||
{
|
{
|
||||||
return noticeId;
|
return noticeId;
|
||||||
|
@ -97,10 +94,6 @@ public class SysNotice extends BaseEntity
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsRead() { return isRead; }
|
|
||||||
|
|
||||||
public void setIsRead(String isRead) { this.isRead = isRead; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
@ -2,7 +2,8 @@ package com.ruoyi.system.domain;
|
||||||
|
|
||||||
public class SysNoticeUser {
|
public class SysNoticeUser {
|
||||||
private Long noticeId;
|
private Long noticeId;
|
||||||
private Long userId;
|
private String userId;
|
||||||
|
private String isRead;
|
||||||
|
|
||||||
public Long getNoticeId() {
|
public Long getNoticeId() {
|
||||||
return noticeId;
|
return noticeId;
|
||||||
|
@ -12,11 +13,15 @@ public class SysNoticeUser {
|
||||||
this.noticeId = noticeId;
|
this.noticeId = noticeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUserId() {
|
public String getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(Long userId) {
|
public void setUserId(String userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIsRead() { return isRead; }
|
||||||
|
|
||||||
|
public void setIsRead(String isRead) { this.isRead = isRead; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public interface SysNoticeMapper
|
||||||
* 消息推送信息获取
|
* 消息推送信息获取
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SysNotice> navbarNoticelist(Long userId);
|
List<SysNotice> navbarNoticelist(String userName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入消息-用户 中间表
|
* 批量插入消息-用户 中间表
|
||||||
|
@ -73,10 +73,35 @@ public interface SysNoticeMapper
|
||||||
*/
|
*/
|
||||||
void insertNoticeUserBatch(List<SysNoticeUser> sysNoticeUsers);
|
void insertNoticeUserBatch(List<SysNoticeUser> sysNoticeUsers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新消息-用户 中间表
|
||||||
|
* @param sysNoticeUser
|
||||||
|
*/
|
||||||
|
void updateSysNoticeUser(SysNoticeUser sysNoticeUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对应消息对象的 人员
|
* 获取对应消息对象的 人员
|
||||||
* @param noticeUserSelect
|
* @param noticeUserSelect
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeEventType
|
||||||
|
*/
|
||||||
|
void deleteNoticeEventUserByType(String noticeEventType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入对应消息对象的 人员
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void insertNoticeEventUserBatch(List<NoticeUserSelect> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeUserSelect
|
||||||
|
*/
|
||||||
|
void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public interface ISysNoticeService
|
||||||
* 导航面板 消息通知
|
* 导航面板 消息通知
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SysNotice> navbarNoticelist(Long userId);
|
List<SysNotice> navbarNoticelist(String userName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入消息-用户 中间表
|
* 批量插入消息-用户 中间表
|
||||||
|
@ -73,10 +73,34 @@ public interface ISysNoticeService
|
||||||
*/
|
*/
|
||||||
void insertNoticeUserBatch(List<SysNoticeUser> sysNoticeUsers);
|
void insertNoticeUserBatch(List<SysNoticeUser> sysNoticeUsers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新消息-用户 中间表
|
||||||
|
* @param sysNoticeUser
|
||||||
|
*/
|
||||||
|
void updateSysNoticeUser(SysNoticeUser sysNoticeUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对应消息对象的 人员
|
* 获取对应消息对象的 人员
|
||||||
* @param noticeUserSelect
|
* @param noticeUserSelect
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeEventType
|
||||||
|
*/
|
||||||
|
void deleteNoticeEventUserByType(String noticeEventType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入对应消息对象的 人员
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void insertNoticeEventUserBatch(List<NoticeUserSelect> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeUserSelect
|
||||||
|
*/
|
||||||
|
void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysNotice> navbarNoticelist(Long userId) {
|
public List<SysNotice> navbarNoticelist(String userName) {
|
||||||
return noticeMapper.navbarNoticelist(userId);
|
return noticeMapper.navbarNoticelist(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,6 +133,15 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
||||||
noticeMapper.insertNoticeUserBatch(sysNoticeUsers);
|
noticeMapper.insertNoticeUserBatch(sysNoticeUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新消息-用户 中间表
|
||||||
|
* @param sysNoticeUser
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateSysNoticeUser(SysNoticeUser sysNoticeUser) {
|
||||||
|
noticeMapper.updateSysNoticeUser(sysNoticeUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对应消息对象的 人员
|
* 获取对应消息对象的 人员
|
||||||
* @param noticeUserSelect
|
* @param noticeUserSelect
|
||||||
|
@ -142,4 +151,31 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
||||||
public List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect) {
|
public List<NoticeUserSelect> listNoticeEventUser(NoticeUserSelect noticeUserSelect) {
|
||||||
return noticeMapper.listNoticeEventUser(noticeUserSelect);
|
return noticeMapper.listNoticeEventUser(noticeUserSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeEventType
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteNoticeEventUserByType(String noticeEventType) {
|
||||||
|
noticeMapper.deleteNoticeEventUserByType(noticeEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入对应消息对象的 人员
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertNoticeEventUserBatch(List<NoticeUserSelect> list) {
|
||||||
|
noticeMapper.insertNoticeEventUserBatch(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对应消息对象的 人员
|
||||||
|
* @param noticeUserSelect
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect) {
|
||||||
|
noticeMapper.deleteNoticeEventUser(noticeUserSelect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="isRead" column="isRead" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNoticeVo">
|
<sql id="selectNoticeVo">
|
||||||
select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark, isRead
|
select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark
|
||||||
from sys_notice
|
from sys_notice
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -71,8 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="noticeContentBit != null and noticeContentBit.length != 0">notice_content = #{noticeContentBit}, </if>
|
<if test="noticeContentBit != null and noticeContentBit.length != 0">notice_content = #{noticeContentBit}, </if>
|
||||||
<if test="status != null and status != ''">status = #{status}, </if>
|
<if test="status != null and status != ''">status = #{status}, </if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
update_time = getdate(),
|
update_time = getdate()
|
||||||
<if test="isRead != null and isRead != ''">isRead = #{isRead}</if>
|
|
||||||
</set>
|
</set>
|
||||||
where notice_id = #{noticeId}
|
where notice_id = #{noticeId}
|
||||||
</update>
|
</update>
|
||||||
|
@ -93,9 +91,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
from sys_notice a
|
from sys_notice a
|
||||||
inner join sys_user_notice b on a.notice_id = b.noticeId
|
inner join sys_user_notice b on a.notice_id = b.noticeId
|
||||||
<where>
|
<where>
|
||||||
and b.userId = #{userId}
|
and b.userId = #{userName}
|
||||||
and CONVERT(date, a.create_time) = CONVERT(date, GETDATE())
|
and CONVERT(date, a.create_time) = CONVERT(date, GETDATE())
|
||||||
and a.status = '0' and a.isRead = '0'
|
and a.status = '0' and b.isRead = '0'
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
@ -106,11 +104,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
<foreach collection="list" item="item" index="index" separator=",">
|
||||||
(
|
(
|
||||||
#{item.noticeId,jdbcType=INTEGER},
|
#{item.noticeId,jdbcType=INTEGER},
|
||||||
#{item.userId,jdbcType=INTEGER}
|
#{item.userId,jdbcType=VARCHAR}
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysNoticeUser" parameterType="SysNoticeUser">
|
||||||
|
update sys_user_notice set isRead = #{isRead} where noticeId = #{noticeId} and userId = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="listNoticeEventUser" resultType="NoticeUserSelect">
|
<select id="listNoticeEventUser" resultType="NoticeUserSelect">
|
||||||
select a.notice_event_user_id userName, b.nick_name nickName
|
select a.notice_event_user_id userName, b.nick_name nickName
|
||||||
from sys_event_user a
|
from sys_event_user a
|
||||||
|
@ -118,4 +120,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where a.notice_event_type = #{noticeEventType}
|
where a.notice_event_type = #{noticeEventType}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteNoticeEventUserByType" parameterType="String">
|
||||||
|
delete from sys_event_user where notice_event_type = #{noticeEventType}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="insertNoticeEventUserBatch">
|
||||||
|
insert into sys_event_user(notice_event_type,notice_event_user_id)
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="item" index="index" separator=",">
|
||||||
|
(
|
||||||
|
#{item.noticeEventType,jdbcType=VARCHAR},
|
||||||
|
#{item.userName,jdbcType=VARCHAR}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteNoticeEventUser" parameterType="NoticeUserSelect">
|
||||||
|
delete from sys_event_user where notice_event_type = #{noticeEventType} and notice_event_user_id = #{userName}
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -69,3 +69,20 @@ export function listNoticeEventUser(query) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存对应消息对象的 人员
|
||||||
|
export function saveNoticeEventUser(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/notice/saveNoticeEventUser',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除对应消息对象的 人员
|
||||||
|
export function delNoticeEventUser(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/notice/delNoticeEventUser',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initWebSocket() {
|
initWebSocket() {
|
||||||
var userId = this.$store.state.user.id;
|
var userName = this.$store.state.user.name;
|
||||||
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
||||||
// 当前浏览器Location对象
|
// 当前浏览器Location对象
|
||||||
const nowLocation = window.location;
|
const nowLocation = window.location;
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
const webSocketApiUrl = 'ws://' + host + '/' + websocket_pattern;
|
const webSocketApiUrl = 'ws://' + host + '/' + websocket_pattern;
|
||||||
// 当前WebSocket的请求地址前缀,
|
// 当前WebSocket的请求地址前缀,
|
||||||
// /websocket/template-push/ 就是我后端配置的websocket端点地址
|
// /websocket/template-push/ 就是我后端配置的websocket端点地址
|
||||||
let url = webSocketApiUrl + '/websocket/message/'+userId;
|
let url = webSocketApiUrl + '/websocket/message/'+userName;
|
||||||
this.websock = new WebSocket(url)
|
this.websock = new WebSocket(url)
|
||||||
this.websock.onopen = this.websocketOnopen
|
this.websock.onopen = this.websocketOnopen
|
||||||
this.websock.onerror = this.websocketOnerror
|
this.websock.onerror = this.websocketOnerror
|
||||||
|
|
|
@ -289,6 +289,7 @@
|
||||||
|
|
||||||
//第一步要做的 checkedUsers 为数组如['admin','ry'] 在父组件调用此方法并传入要回显的数组可进行复选框回显操作
|
//第一步要做的 checkedUsers 为数组如['admin','ry'] 在父组件调用此方法并传入要回显的数组可进行复选框回显操作
|
||||||
getAllUserList(checkedUsers = []) {
|
getAllUserList(checkedUsers = []) {
|
||||||
|
this.userList = [];
|
||||||
//查出所有的用户,用于根据不同情况筛选显示
|
//查出所有的用户,用于根据不同情况筛选显示
|
||||||
listUser({pageNum: 1,pageSize: 2147483647,status: "0"}).then(response => {
|
listUser({pageNum: 1,pageSize: 2147483647,status: "0"}).then(response => {
|
||||||
this.allUserList = response.rows;
|
this.allUserList = response.rows;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" @click="open" size="mini" :disabled="this.noticeEventType==''">选择人员</el-button>
|
<el-button type="primary" icon="el-icon-search" @click="open" size="mini" :disabled="this.noticeEventType==''">选择人员</el-button>
|
||||||
<el-button :disabled="this.noticeEventType==''" @click="saveNoticeEventUser">保 存</el-button>
|
<!--<el-button :disabled="this.noticeEventType==''" @click="saveNoticeEventUser">保 存</el-button>-->
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div class="mt10">
|
<div class="mt10">
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<el-card class="mb20">
|
<el-card class="mb20">
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<span>{{ item.nickName }}</span>
|
<span>{{ item.nickName }}</span>
|
||||||
<el-button style="float: right; padding: 3px 0" type="text">删除</el-button>
|
<el-button style="float: right; padding: 3px 0" type="text" @click="delNoticeEventUser(item)">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -35,13 +35,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listNoticeEventUser } from "@/api/system/notice";
|
import { listNoticeEventUser,saveNoticeEventUser,delNoticeEventUser } from "@/api/system/notice";
|
||||||
|
|
||||||
/** 导入选人组件 */
|
/** 导入选人组件 */
|
||||||
import PeopleSelect from "@/views/components/Tools/PeopleSelect/index.vue";
|
import PeopleSelect from "@/views/components/Tools/PeopleSelect/index.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "peopleSelect",
|
name: "noticeUserSelect",
|
||||||
dicts: ['notice_event_user'],
|
dicts: ['notice_event_user'],
|
||||||
components:{
|
components:{
|
||||||
// 注册组件
|
// 注册组件
|
||||||
|
@ -73,7 +73,33 @@
|
||||||
},
|
},
|
||||||
//保存
|
//保存
|
||||||
saveNoticeEventUser(){
|
saveNoticeEventUser(){
|
||||||
console.log(this.selectedPeoples)
|
let dataArr = [];
|
||||||
|
let noticeEventType = this.noticeEventType;
|
||||||
|
this.selectedPeoples.forEach(function(item){
|
||||||
|
let data = {};
|
||||||
|
data.noticeEventType = noticeEventType;
|
||||||
|
data.userName = item.userName;
|
||||||
|
data.nickName = item.nickName;
|
||||||
|
dataArr.push(data);
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(dataArr)
|
||||||
|
saveNoticeEventUser(dataArr).then(response => {
|
||||||
|
this.$modal.msgSuccess("保存成功");
|
||||||
|
this.selectEvent(noticeEventType)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
//删除
|
||||||
|
delNoticeEventUser(item){
|
||||||
|
let data = {};
|
||||||
|
let noticeEventType = this.noticeEventType;
|
||||||
|
data.noticeEventType = noticeEventType;
|
||||||
|
data.userName = item.userName;
|
||||||
|
delNoticeEventUser(data).then(response => {
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
this.selectEvent(noticeEventType)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
//打开选人弹窗
|
//打开选人弹窗
|
||||||
|
@ -87,6 +113,8 @@
|
||||||
this.selectedPeoples = this.selectedPeoples.concat(nickNameList)
|
this.selectedPeoples = this.selectedPeoples.concat(nickNameList)
|
||||||
this.selectedPeoples = this.unique(this.selectedPeoples)
|
this.selectedPeoples = this.unique(this.selectedPeoples)
|
||||||
this.peopleOpen=false;
|
this.peopleOpen=false;
|
||||||
|
|
||||||
|
this.saveNoticeEventUser();
|
||||||
},
|
},
|
||||||
|
|
||||||
//数组去重
|
//数组去重
|
||||||
|
|
Loading…
Reference in New Issue