add: 新增消息通知
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
package org.nl.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2023/5/9
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum NoticeEnum {
|
||||
HAVE_READ_OFF("1","未读"),
|
||||
HAVE_READ_ON("2", "已读"),
|
||||
DEAL_STATUS_NO("1", "未处理"),
|
||||
DEAL_STATUS_YES("2", "已处理"),
|
||||
DEAL_STATUS_NO_NEED("3", "无需处理");
|
||||
|
||||
private final String value;
|
||||
private final String desc;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -36,6 +37,14 @@ public class SysLogController {
|
||||
return new ResponseEntity<>(TableDataInfo.build(logService.queryAll(criteria,pageable)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/user")
|
||||
// @ApiOperation("用户日志查询")
|
||||
public ResponseEntity<Object> queryUserLog(@RequestParam Map criteria, PageQuery pageable){
|
||||
criteria.put("log_type","INFO");
|
||||
criteria.put("username", SecurityUtils.getCurrentUsername());
|
||||
return new ResponseEntity<>(TableDataInfo.build(logService.queryAll(criteria,pageable)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/error")
|
||||
@ApiOperation("错误日志查询")
|
||||
// @SaCheckPermission("@el.check()")
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package org.nl.system.controller.notice;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "消息通知管理")
|
||||
@RequestMapping("/api/notice")
|
||||
public class SysNoticeController {
|
||||
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询消息通知")
|
||||
@ApiOperation("查询消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
|
||||
return new ResponseEntity<>(TableDataInfo.build(noticeService.queryAll(whereJson,page)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增消息通知")
|
||||
@ApiOperation("新增消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysNotice entity){
|
||||
noticeService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改消息通知")
|
||||
@ApiOperation("修改消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysNotice entity){
|
||||
noticeService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除消息通知")
|
||||
@ApiOperation("删除消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
noticeService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("获取未读的接收消息条数")
|
||||
@GetMapping("/countByReceiveNotRead")
|
||||
public ResponseEntity<Object> countByReceiveNotRead(){
|
||||
return new ResponseEntity<>(noticeService.countByReceiveNotRead(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("接收消息分页")
|
||||
@GetMapping("/pageByReceive")
|
||||
public ResponseEntity<Object> pageByReceive(){
|
||||
return new ResponseEntity<>(noticeService.pageByReceive(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("标为已读")
|
||||
@PostMapping("/read")
|
||||
public ResponseEntity<Object> read(@RequestBody String id){
|
||||
noticeService.read(id);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("消息详情")
|
||||
@PostMapping("/findById")
|
||||
public ResponseEntity<Object> findById(@RequestBody String id){
|
||||
return new ResponseEntity<>(noticeService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("修改已处理")
|
||||
@PostMapping("/deal")
|
||||
public ResponseEntity<Object> deal(@RequestBody String id){
|
||||
noticeService.deal(id);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("批量已读")
|
||||
@PostMapping("/changeRead")
|
||||
@ApiOperation("批量已读")
|
||||
public ResponseEntity<Object> changeRead(@RequestBody JSONObject jsonObject) {
|
||||
noticeService.changeRead(jsonObject);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ package org.nl.system.controller.user;
|
||||
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -99,22 +101,23 @@ public class UserController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/* @ApiOperation("修改密码")
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/updatePass")
|
||||
public ResponseEntity<Object> updatePass(@RequestBody UserPassVo passVo) throws Exception {
|
||||
public ResponseEntity<Object> updatePass(@RequestBody JSONObject passVo) throws Exception {
|
||||
// 解密,得到字符密码
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
|
||||
User user = userService.findByName(SecurityUtils.getCurrentUsername());
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("oldPass"));
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("newPass"));
|
||||
SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, SecurityUtils.getCurrentUsername()));
|
||||
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) {
|
||||
throw new BadRequestException("新密码不能与旧密码相同");
|
||||
}
|
||||
userService.updatePass(user.getUsername(),SaSecureUtil.md5BySalt(newPass, "salt"));
|
||||
user.setPassword(SaSecureUtil.md5BySalt(newPass, "salt"));
|
||||
userService.updateById(user);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}*/
|
||||
}
|
||||
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/updateAvatar")
|
||||
|
||||
@@ -36,10 +36,12 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
public IPage<SysLog> queryAll(Map whereJson, PageQuery pageable) {
|
||||
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry"))?whereJson.get("blurry").toString():null;
|
||||
String log_type = ObjectUtil.isNotEmpty(whereJson.get("log_type"))?whereJson.get("log_type").toString():null;
|
||||
String username = ObjectUtil.isNotEmpty(whereJson.get("username"))?whereJson.get("username").toString():null;
|
||||
String begin_time = ObjectUtil.isNotEmpty(whereJson.get("begin_time"))?whereJson.get("begin_time").toString():null;
|
||||
String end_time = ObjectUtil.isNotEmpty(whereJson.get("end_time"))?whereJson.get("end_time").toString():null;
|
||||
LambdaQueryWrapper<SysLog> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(ObjectUtil.isNotEmpty(log_type), SysLog::getLog_type, log_type)
|
||||
.eq(ObjectUtil.isNotEmpty(username), SysLog::getUsername, username)
|
||||
.like(ObjectUtil.isNotEmpty(blurry), SysLog::getDescription, blurry)
|
||||
.le(ObjectUtil.isNotEmpty(end_time), SysLog::getCreate_time, end_time)
|
||||
.ge(ObjectUtil.isNotEmpty(begin_time), SysLog::getCreate_time, begin_time)
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.nl.system.service.notice;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public interface ISysNoticeService extends IService<SysNotice> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<SysNotice>
|
||||
*/
|
||||
IPage<SysNotice> queryAll(Map whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param entity /
|
||||
*/
|
||||
void create(SysNotice entity);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param entity /
|
||||
*/
|
||||
void update(SysNotice entity);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 获取未读的接收消息条数
|
||||
*/
|
||||
Integer countByReceiveNotRead();
|
||||
|
||||
/**
|
||||
* 获取不同类型的前三条信息
|
||||
* @return
|
||||
*/
|
||||
LinkedList<List<SysNotice>> pageByReceive();
|
||||
|
||||
/**
|
||||
* 标记已读
|
||||
* @param id
|
||||
*/
|
||||
void read(String id);
|
||||
|
||||
/**
|
||||
* 处理信息
|
||||
* @param id
|
||||
*/
|
||||
void deal(String id);
|
||||
|
||||
/**
|
||||
* 批量已读
|
||||
* @param jsonObject
|
||||
*/
|
||||
void changeRead(JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* 写入信息
|
||||
* @param msg
|
||||
* @param title
|
||||
* @param type
|
||||
*/
|
||||
void createNotice(String msg, String title, String type);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.nl.system.service.notice.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_notice")
|
||||
public class SysNotice implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "notice_id", type = IdType.NONE)
|
||||
@ApiModelProperty(value = "信息标识")
|
||||
private String notice_id;
|
||||
|
||||
@ApiModelProperty(value = "信息标题")
|
||||
private String notice_title;
|
||||
|
||||
@ApiModelProperty(value = "信息内容")
|
||||
private String notice_content;
|
||||
|
||||
@ApiModelProperty(value = "信息类型")
|
||||
private String notice_type;
|
||||
|
||||
@ApiModelProperty(value = "读取状态")
|
||||
private String have_read;
|
||||
|
||||
@ApiModelProperty(value = "读取时间")
|
||||
private String read_time;
|
||||
|
||||
@ApiModelProperty(value = "处理状态")
|
||||
private String deal_status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String create_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.system.service.notice.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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="org.nl.system.service.notice.dao.mapper.SysNoticeMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.nl.system.service.notice.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Data
|
||||
public class SysNoticeDto implements Serializable {
|
||||
|
||||
/** 信息标识 */
|
||||
private String notice_id;
|
||||
|
||||
/** 信息标题 */
|
||||
private String notice_title;
|
||||
|
||||
/** 信息内容 */
|
||||
private String notice_content;
|
||||
|
||||
/** 信息类型 */
|
||||
private String notice_type;
|
||||
|
||||
/** 读取状态 */
|
||||
private String have_read;
|
||||
|
||||
/** 读取时间 */
|
||||
private String read_time;
|
||||
|
||||
/** 处理状态 */
|
||||
private String deal_status;
|
||||
|
||||
/** 创建时间 */
|
||||
private String create_time;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.system.service.notice.dto;
|
||||
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public class SysNoticeQuery extends BaseQuery<SysNotice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package org.nl.system.service.notice.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.enums.NoticeEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.mnt.websocket.MsgType;
|
||||
import org.nl.common.mnt.websocket.SocketMsg;
|
||||
import org.nl.common.mnt.websocket.WebSocketServer;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.system.service.notice.dao.mapper.SysNoticeMapper;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @description 服务实现
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
|
||||
@Autowired
|
||||
private SysNoticeMapper sysNoticeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDictMapper dictMapper;
|
||||
|
||||
@Autowired
|
||||
private WebSocketServer webSocketServer;
|
||||
|
||||
@Override
|
||||
public IPage<SysNotice> queryAll(Map whereJson, PageQuery page){
|
||||
String notice_title = ObjectUtil.isNotEmpty(whereJson.get("notice_title"))?whereJson.get("notice_title").toString():null;
|
||||
String notice_type = ObjectUtil.isNotEmpty(whereJson.get("notice_type"))?whereJson.get("notice_type").toString():null;
|
||||
String have_read = ObjectUtil.isNotEmpty(whereJson.get("have_read"))?whereJson.get("have_read").toString():null;
|
||||
String deal_status = ObjectUtil.isNotEmpty(whereJson.get("deal_status"))?whereJson.get("deal_status").toString():null;
|
||||
LambdaQueryWrapper<SysNotice> lam = new LambdaQueryWrapper<>();
|
||||
lam.like(ObjectUtil.isNotEmpty(notice_title), SysNotice::getNotice_title, notice_title)
|
||||
.eq(ObjectUtil.isNotEmpty(notice_type), SysNotice::getNotice_type, notice_type)
|
||||
.eq(ObjectUtil.isNotEmpty(have_read), SysNotice::getHave_read, have_read)
|
||||
.eq(ObjectUtil.isNotEmpty(deal_status), SysNotice::getDeal_status, deal_status)
|
||||
.orderByAsc(SysNotice::getHave_read)
|
||||
.orderByDesc(SysNotice::getCreate_time);
|
||||
IPage<SysNotice> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
sysNoticeMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SysNotice entity) {
|
||||
String now = DateUtil.now();
|
||||
|
||||
entity.setNotice_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setCreate_time(now);
|
||||
sysNoticeMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(SysNotice entity) {
|
||||
SysNotice dto = sysNoticeMapper.selectById(entity.getNotice_id());
|
||||
if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
sysNoticeMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Set<String> ids) {
|
||||
// 真删除
|
||||
sysNoticeMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countByReceiveNotRead() {
|
||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>().eq(SysNotice::getHave_read, NoticeEnum.HAVE_READ_OFF.getValue()));
|
||||
return ObjectUtil.isNotEmpty(sysNotices)?sysNotices.size():0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<List<SysNotice>> pageByReceive() {
|
||||
LinkedList<List<SysNotice>> result = new LinkedList<>();
|
||||
List<Dict> dictList = dictMapper.selectList(new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getCode, "notice_type")
|
||||
.orderByAsc(Dict::getDict_sort));
|
||||
dictList.forEach(dict -> {
|
||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
||||
.eq(SysNotice::getNotice_type, dict.getValue())
|
||||
.eq(SysNotice::getHave_read, NoticeEnum.HAVE_READ_OFF.getValue())
|
||||
.orderByDesc(SysNotice::getCreate_time)
|
||||
.last("LIMIT 0,3"));
|
||||
result.add(sysNotices);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String id) {
|
||||
SysNotice notice = this.getById(id);
|
||||
if (ObjectUtil.isEmpty(notice)) {
|
||||
throw new BadRequestException("该信息不存在!");
|
||||
}
|
||||
notice.setHave_read(NoticeEnum.HAVE_READ_ON.getValue());
|
||||
notice.setRead_time(DateUtil.now());
|
||||
sysNoticeMapper.updateById(notice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deal(String id) {
|
||||
SysNotice notice = this.getById(id);
|
||||
if (ObjectUtil.isEmpty(notice)) {
|
||||
throw new BadRequestException("该信息不存在!");
|
||||
}
|
||||
// 设置处理
|
||||
notice.setDeal_status(NoticeEnum.DEAL_STATUS_YES.getValue());
|
||||
// 判断是否读取
|
||||
if (notice.getHave_read().equals(NoticeEnum.HAVE_READ_OFF.getValue())) {
|
||||
// 标记已读并设置读取时间
|
||||
notice.setHave_read(NoticeEnum.HAVE_READ_ON.getValue());
|
||||
notice.setRead_time(DateUtil.now());
|
||||
}
|
||||
sysNoticeMapper.updateById(notice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeRead(JSONObject jsonObject) {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
String haveRead = jsonObject.getString("have_read");
|
||||
List<SysNotice> sysNotices = JSON.parseArray(data.toJSONString(), SysNotice.class);
|
||||
sysNotices.forEach(sysNotice -> sysNotice.setHave_read(haveRead));
|
||||
this.updateBatchById(sysNotices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createNotice(String msg, String title, String type) {
|
||||
// 获取标题相同的信息
|
||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>().eq(SysNotice::getNotice_title, title));
|
||||
if (ObjectUtil.isNotEmpty(sysNotices)) return;
|
||||
SysNotice noticeDto = SysNotice.builder()
|
||||
.notice_id(IdUtil.getSnowflake(1,1).nextIdStr())
|
||||
.notice_type(type)
|
||||
.notice_title(title)
|
||||
.notice_content(msg)
|
||||
.deal_status(NoticeEnum.DEAL_STATUS_NO.getValue())
|
||||
.have_read(NoticeEnum.HAVE_READ_OFF.getValue())
|
||||
.create_time(DateUtil.now())
|
||||
.build();
|
||||
// 插入
|
||||
sysNoticeMapper.insert(noticeDto);
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("data", "notice_message_update");
|
||||
SocketMsg messageInfo = new SocketMsg(res, MsgType.INFO);
|
||||
try {
|
||||
webSocketServer.sendInfo(messageInfo, "messageInfo");
|
||||
} catch (IOException e) {
|
||||
throw new BadRequestException("消息发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -66,6 +66,7 @@
|
||||
"sortablejs": "1.8.4",
|
||||
"throttle-debounce": "^5.0.0",
|
||||
"vue": "2.6.10",
|
||||
"vue-bus": "^1.2.1",
|
||||
"vue-color": "^2.8.1",
|
||||
"vue-count-to": "1.0.13",
|
||||
"vue-cropper": "0.4.9",
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<el-tooltip content="全屏缩放" effect="dark" placement="bottom">
|
||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
<notice-icon class="right-menu-item"/>
|
||||
<notice-icon-reader ref="noticeIconReader"/>
|
||||
|
||||
<!-- <el-tooltip content="布局设置" effect="dark" placement="bottom">
|
||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||
@@ -24,9 +26,7 @@
|
||||
<img :src="Avatar" class="user-avatar">
|
||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover">
|
||||
<div class="avatar-wrapper">
|
||||
<!-- <img :src="Avatar" class="user-avatar" style="border: #f5141e 1px solid">-->
|
||||
<span class="user-nickname">{{ user.person_name }}</span>
|
||||
<!-- <span class="user-nickname">258</span>-->
|
||||
</div>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<span style="display:block;" @click="show = true">
|
||||
@@ -61,9 +61,13 @@ import Screenfull from '@/components/Screenfull'
|
||||
import SizeSelect from '@/components/SizeSelect'
|
||||
import Search from '@/components/HeaderSearch'
|
||||
import Avatar from '@/assets/images/avatar.png'
|
||||
import NoticeIcon from '@/views/system/notice/NoticeIcon.vue'
|
||||
import NoticeIconReader from '@/views/system/notice/NoticeIconReader.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
NoticeIconReader,
|
||||
NoticeIcon,
|
||||
Breadcrumb,
|
||||
Hamburger,
|
||||
Screenfull,
|
||||
@@ -102,6 +106,9 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initWebSocket()
|
||||
},
|
||||
methods: {
|
||||
toggleSideBar() {
|
||||
this.$store.dispatch('app/toggleSideBar')
|
||||
@@ -119,6 +126,35 @@ export default {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.reload()
|
||||
})
|
||||
},
|
||||
initWebSocket() {
|
||||
// const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'messageInfo'
|
||||
const wsUri = window.g.prod.VUE_APP_BASE_API.replace('http', 'ws') + '/webSocket/' + 'messageInfo'
|
||||
this.websock = new WebSocket(wsUri)
|
||||
this.websock.onerror = this.webSocketOnError
|
||||
this.websock.onmessage = this.webSocketOnMessage
|
||||
},
|
||||
webSocketOnError(e) {
|
||||
this.$notify({
|
||||
title: 'WebSocket连接发生错误',
|
||||
type: 'error',
|
||||
duration: 0
|
||||
})
|
||||
},
|
||||
webSocketOnMessage(e) {
|
||||
const data = JSON.parse(e.data)
|
||||
if (data.msgType === 'INFO') {
|
||||
console.log('data', data)
|
||||
this.$bus.emit(data.msg.data, data.msg.msgType)
|
||||
} else if (data.msgType === 'ERROR') {
|
||||
this.$notify({
|
||||
title: '',
|
||||
message: data.msg,
|
||||
dangerouslyUseHTMLString: true,
|
||||
type: 'error',
|
||||
duration: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ import { addDateRange, handleTree, parseTime, resetForm, selectDictLabel, select
|
||||
|
||||
import { getValueByCode } from '@/views/system/param/param'
|
||||
|
||||
import VueBus from 'vue-bus'
|
||||
|
||||
LogicFlow.use(Menu)
|
||||
|
||||
Vue.component('tinymce', Tinymce)
|
||||
@@ -67,6 +69,7 @@ Vue.use(VueHighlightJS)
|
||||
Vue.use(mavonEditor)
|
||||
Vue.use(permission)
|
||||
Vue.use(dict)
|
||||
Vue.use(VueBus)
|
||||
// 全局设置控件样式https://codeantenna.com/a/0IN5FMJk5h
|
||||
Element.Table.props.border = { type: Boolean, default: true }
|
||||
Element.TableColumn.props.align = { type: String, default: 'center' }
|
||||
|
||||
128
nladmin-ui/src/views/system/notice/NoticeIcon.vue
Normal file
128
nladmin-ui/src/views/system/notice/NoticeIcon.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<el-popover
|
||||
placement="top-end"
|
||||
width="450"
|
||||
trigger="manual"
|
||||
v-model="visible">
|
||||
<div style="margin: 5px" v-loading="loading">
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id">
|
||||
<el-empty v-show="notReadMsgList[d.value-1].length == 0" description="暂无信息" ></el-empty>
|
||||
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
|
||||
<a href="javascript:" @click="showMessage(o)">
|
||||
<el-row @click="showMessage">
|
||||
<el-col :span="6">
|
||||
<el-tag type="danger">{{ dict.label.notice_type[o.notice_type] }}</el-tag>
|
||||
</el-col>
|
||||
<el-col :span="9" style="font-weight: bolder">{{o.notice_title}}</el-col>
|
||||
<el-col :span="9" style="color: #cccccc">{{o.create_time}}</el-col>
|
||||
</el-row>
|
||||
<el-divider ></el-divider>
|
||||
</a>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div style="text-align: right">
|
||||
<el-button type="text" @click="visible = !visible">取消</el-button>
|
||||
<el-button type="text" @click="toSiteMessage" >查看更多>></el-button>
|
||||
</div>
|
||||
</div>
|
||||
<span slot="reference" @click="fetchNotice">
|
||||
<el-badge :value="notReadMsgCount" :hidden="notReadMsgCount==0">
|
||||
<el-icon class="el-icon-bell" style="font-size: 22px;"></el-icon>
|
||||
</el-badge>
|
||||
</span>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudNotice from './sysNotice'
|
||||
import { NOTICE_MESSAGE_UPDATE, NOTICE_SHOW_MESSAGE } from './VueBaseCode'
|
||||
export default {
|
||||
dicts: ['deal_status', 'have_read_type', 'notice_type'],
|
||||
name: 'NoticeIcon',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
activeName: '1',
|
||||
// 未读消息数量
|
||||
notReadMsgCount: 0,
|
||||
// 消息内容
|
||||
notReadMsgList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 打开列表页
|
||||
*/
|
||||
fetchNotice() {
|
||||
if (this.visible) {
|
||||
this.visible = false
|
||||
this.loading = false
|
||||
} else {
|
||||
this.visible = true
|
||||
this.loading = true
|
||||
// 消息列表
|
||||
this.getMessage()
|
||||
}
|
||||
},
|
||||
getMessage() {
|
||||
crudNotice.pageByReceive().then(res => {
|
||||
this.notReadMsgList = res
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 未读的消息数量
|
||||
*/
|
||||
receivedCount() {
|
||||
// 查询当前用户的未读消息数量
|
||||
crudNotice.countByReceiveNotRead().then(res => {
|
||||
this.notReadMsgCount = res
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 查看消息
|
||||
*/
|
||||
showMessage(message) {
|
||||
// 标记已读
|
||||
crudNotice.read(message.notice_id).then(() => {
|
||||
this.receivedCount()
|
||||
})
|
||||
this.$bus.emit(NOTICE_SHOW_MESSAGE, message)
|
||||
this.visible = false
|
||||
},
|
||||
/**
|
||||
* 跳转到站内信界面
|
||||
*/
|
||||
toSiteMessage() {
|
||||
this.$router.push({
|
||||
path: '/monitor/notice'
|
||||
})
|
||||
this.visible = false
|
||||
},
|
||||
handleClick(tab, event) {
|
||||
// console.log(this.dict.notice_type)
|
||||
// console.log(tab, event)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getMessage()
|
||||
this.receivedCount()
|
||||
this.$bus.on(NOTICE_MESSAGE_UPDATE, this.receivedCount) // 监听事件
|
||||
},
|
||||
destroyed() {
|
||||
this.$bus.off(NOTICE_MESSAGE_UPDATE)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/deep/.el-badge__content.is-fixed {
|
||||
top: 10px;
|
||||
}
|
||||
.el-divider{
|
||||
margin: 8px 0;
|
||||
}
|
||||
</style>
|
||||
122
nladmin-ui/src/views/system/notice/NoticeIconReader.vue
Normal file
122
nladmin-ui/src/views/system/notice/NoticeIconReader.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="消息详情"
|
||||
:visible.sync="visible"
|
||||
:modal-append-to-body="false"
|
||||
:append-to-body="true"
|
||||
width="40%">
|
||||
<div style="margin-top: 5px">
|
||||
<el-descriptions class="margin-top" :column="3" border>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
<i class="el-icon-user"></i>
|
||||
标题
|
||||
</template>
|
||||
{{message.notice_title}}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
<i class="el-icon-mobile-phone"></i>
|
||||
信息类型
|
||||
</template>
|
||||
<el-tag size="small" type="danger">
|
||||
{{ dict.label.notice_type[message.notice_type] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
<i class="el-icon-location-outline"></i>
|
||||
创建时间
|
||||
</template>
|
||||
{{ message.create_time }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
<i class="el-icon-tickets"></i>
|
||||
处理情况
|
||||
</template>
|
||||
<el-tag size="small" type="warning">
|
||||
{{ dict.label.deal_status[message.deal_status] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
<i class="el-icon-office-building"></i>
|
||||
内容
|
||||
</template>
|
||||
{{message.notice_content}}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" size="mini" @click="handleCancel">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudNotice from './sysNotice'
|
||||
import { NOTICE_SHOW_MESSAGE } from './VueBaseCode'
|
||||
export default {
|
||||
dicts: ['deal_status', 'have_read_type', 'notice_type'],
|
||||
name: 'NoticeIconReader',
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
confirmLoading: false,
|
||||
message: {
|
||||
have_read: false,
|
||||
notice_type: null,
|
||||
deal_status: null,
|
||||
notice_content: null,
|
||||
notice_id: '',
|
||||
create_time: '',
|
||||
notice_title: '',
|
||||
read_time: ''
|
||||
},
|
||||
bodyStyle: {
|
||||
padding: '0',
|
||||
maxHeight: (window.innerHeight * 0.6) + 'px',
|
||||
'overflow-y': 'auto'
|
||||
},
|
||||
modelStyle: {
|
||||
width: '60%',
|
||||
style: { top: '10px' },
|
||||
fullScreen: false
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 显示消息内容
|
||||
*/
|
||||
show(row) {
|
||||
console.log('sss', row)
|
||||
this.visible = true
|
||||
this.confirmLoading = true
|
||||
this.message = row
|
||||
crudNotice.findById(row.notice_id).then(res => {
|
||||
this.message = res
|
||||
this.confirmLoading = false
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 关闭
|
||||
*/
|
||||
handleCancel() {
|
||||
this.visible = false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 绑定查看站内信消息事件
|
||||
this.$bus.on(NOTICE_SHOW_MESSAGE, this.show)
|
||||
},
|
||||
destroyed() {
|
||||
this.$bus.off(NOTICE_SHOW_MESSAGE)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
15
nladmin-ui/src/views/system/notice/VueBaseCode.js
Normal file
15
nladmin-ui/src/views/system/notice/VueBaseCode.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/* 消息服务 */
|
||||
/**
|
||||
* 显示站内信消息
|
||||
*/
|
||||
export const NOTICE_SHOW_MESSAGE = 'notice_show_message'
|
||||
/**
|
||||
* 通知消息发生消息更新 主要是 未读数量更新
|
||||
*/
|
||||
export const NOTICE_MESSAGE_UPDATE = 'notice_message_update'
|
||||
|
||||
/* 其他 */
|
||||
/**
|
||||
* ws测试事件
|
||||
*/
|
||||
export const EVENT_TEST_WEBSOCKET = 'event_test_websocket'
|
||||
270
nladmin-ui/src/views/system/notice/index.vue
Normal file
270
nladmin-ui/src/views/system/notice/index.vue
Normal file
@@ -0,0 +1,270 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="90px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="信息标题">
|
||||
<el-input
|
||||
v-model="query.notice_title"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="请输入标题"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="信息类型">
|
||||
<el-select
|
||||
v-model="query.notice_type"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="信息类型"
|
||||
class="filter-item"
|
||||
@change="hand"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.notice_type"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="读取状态">
|
||||
<el-select
|
||||
v-model="query.have_read"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="读取状态"
|
||||
class="filter-item"
|
||||
@change="hand"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.have_read_type"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理情况">
|
||||
<el-select
|
||||
v-model="query.deal_status"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="处理情况"
|
||||
class="filter-item"
|
||||
@change="hand"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.deal_status"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="success"
|
||||
icon="el-icon-circle-check"
|
||||
:disabled="crud.selections.length === 0"
|
||||
@click="changeRead(crud.selections)"
|
||||
>
|
||||
批量已读
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="信息标题" prop="notice_title">
|
||||
<el-input v-model="form.notice_title" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="信息内容" prop="notice_content">
|
||||
<el-input v-model="form.notice_content" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="信息类型" prop="notice_type">
|
||||
<el-input v-model="form.notice_type" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="读取状态" prop="have_read">
|
||||
<el-input v-model="form.have_read" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="读取时间">
|
||||
<el-input v-model="form.read_time" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="处理状态" prop="deal_status">
|
||||
<el-input v-model="form.deal_status" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="create_time">
|
||||
<el-input v-model="form.create_time" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="notice_title" label="信息标题" :min-width="flexWidth('notice_title',crud.data,'信息标题')" />
|
||||
<el-table-column prop="notice_content" label="信息内容" :min-width="flexWidth('notice_content',crud.data,'信息内容')" />
|
||||
<el-table-column prop="notice_type" label="信息类型" :min-width="flexWidth('notice_type',crud.data,'信息类型')">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.notice_type == 1" type="danger">{{ dict.label.notice_type[scope.row.notice_type] }}</el-tag>
|
||||
<el-tag v-else type="warning">{{ dict.label.notice_type[scope.row.notice_type] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="have_read" label="读取状态" :min-width="flexWidth('have_read',crud.data,'读取状态')" >
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.have_read == 1" type="danger">{{ dict.label.have_read_type[scope.row.have_read] }}</el-tag>
|
||||
<el-tag v-else type="success">{{ dict.label.have_read_type[scope.row.have_read] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="read_time" label="读取时间" :min-width="flexWidth('read_time',crud.data,'读取时间')" />
|
||||
<el-table-column prop="deal_status" label="处理状态" :min-width="flexWidth('deal_status',crud.data,'处理状态')" >
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.deal_status == 1" type="info">{{ dict.label.deal_status[scope.row.deal_status] }}</el-tag>
|
||||
<el-tag v-else>{{ dict.label.deal_status[scope.row.deal_status] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
|
||||
<el-table-column v-permission="[]" label="操作" width="230px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
slot="left"
|
||||
icon="el-icon-view"
|
||||
@click="show(scope.row)">
|
||||
查看
|
||||
</el-button>
|
||||
<el-button
|
||||
type="text"
|
||||
slot="left"
|
||||
icon="el-icon-help"
|
||||
@click="deal(scope.row)">
|
||||
处理
|
||||
</el-button>
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
:is-visiable-edit="false"
|
||||
style="display: inline"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import crudNotice from './sysNotice'
|
||||
import rrOperation from '@crud/RR.operation.vue'
|
||||
import crudOperation from '@crud/CRUD.operation.vue'
|
||||
import udOperation from '@crud/UD.operation.vue'
|
||||
import pagination from '@crud/Pagination.vue'
|
||||
import { NOTICE_SHOW_MESSAGE, NOTICE_MESSAGE_UPDATE } from './VueBaseCode'
|
||||
|
||||
const defaultForm = { notice_id: null, notice_title: null, notice_content: null, notice_type: null, have_read: null, read_time: null, deal_status: null, create_time: null }
|
||||
export default {
|
||||
name: 'Notice',
|
||||
dicts: ['deal_status', 'have_read_type', 'notice_type'],
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '消息通知',
|
||||
url: 'api/notice',
|
||||
idField: 'notice_id',
|
||||
sort: 'notice_id,desc',
|
||||
crudMethod: { ...crudNotice },
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
del: true,
|
||||
download: false,
|
||||
reset: true
|
||||
}
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {},
|
||||
rules: {
|
||||
notice_title: [
|
||||
{ required: true, message: '信息标题不能为空', trigger: 'blur' }
|
||||
],
|
||||
notice_content: [
|
||||
{ required: true, message: '信息内容不能为空', trigger: 'blur' }
|
||||
],
|
||||
notice_type: [
|
||||
{ required: true, message: '信息类型不能为空', trigger: 'blur' }
|
||||
],
|
||||
have_read: [
|
||||
{ required: true, message: '读取状态不能为空', trigger: 'blur' }
|
||||
],
|
||||
deal_status: [
|
||||
{ required: true, message: '处理状态不能为空', trigger: 'blur' }
|
||||
],
|
||||
create_time: [
|
||||
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
|
||||
]
|
||||
}}
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
show(record) {
|
||||
if (record.have_read == '1') {
|
||||
crudNotice.read(record.notice_id).then(() => {
|
||||
record.have_read = '2'
|
||||
this.$bus.emit(NOTICE_MESSAGE_UPDATE)
|
||||
})
|
||||
}
|
||||
this.$bus.emit(NOTICE_SHOW_MESSAGE, record)
|
||||
this.crud.toQuery()
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
deal(row) {
|
||||
crudNotice.deal(row.notice_id).then(() => {
|
||||
row.have_read = '2'
|
||||
this.$bus.emit(NOTICE_MESSAGE_UPDATE)
|
||||
})
|
||||
this.crud.toQuery()
|
||||
},
|
||||
changeRead(data) {
|
||||
const param = {}
|
||||
param.data = data
|
||||
param.have_read = '2'
|
||||
crudNotice.changeRead(param).then(() => {
|
||||
this.$bus.emit(NOTICE_MESSAGE_UPDATE)
|
||||
})
|
||||
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
94
nladmin-ui/src/views/system/notice/sysNotice.js
Normal file
94
nladmin-ui/src/views/system/notice/sysNotice.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 获取未读信息
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
export function pageByReceive() {
|
||||
return request({
|
||||
url: '/api/notice/pageByReceive',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 未读消息数量
|
||||
*/
|
||||
export function countByReceiveNotRead() {
|
||||
return request({
|
||||
url: '/api/notice/countByReceiveNotRead',
|
||||
method: 'GET'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记为已读
|
||||
*/
|
||||
export function read(id) {
|
||||
return request({
|
||||
url: '/api/notice/read',
|
||||
method: 'post',
|
||||
data: id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记为已修改
|
||||
*/
|
||||
export function deal(id) {
|
||||
return request({
|
||||
url: '/api/notice/deal',
|
||||
method: 'post',
|
||||
data: id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量已读
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
export function changeRead(data) {
|
||||
return request({
|
||||
url: 'api/notice/changeRead',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看消息
|
||||
*/
|
||||
export function findById(id) {
|
||||
return request({
|
||||
url: '/api/notice/findById',
|
||||
method: 'post',
|
||||
data: id
|
||||
})
|
||||
}
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/notice',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/notice/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/notice',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, pageByReceive, countByReceiveNotRead, read, findById, deal, changeRead }
|
||||
@@ -28,7 +28,7 @@
|
||||
<svg-icon icon-class="anq" /> 安全设置
|
||||
<div class="user-right">
|
||||
<a @click="$refs.pass.dialog = true">修改密码</a>
|
||||
<a @click="$refs.email.dialog = true">修改邮箱</a>
|
||||
<!-- <a @click="$refs.email.dialog = true">修改邮箱</a>-->
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -41,7 +41,7 @@
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane label="用户资料" name="first">
|
||||
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 10px;" size="mini" label-width="65px">
|
||||
<el-form-item label="姓名" prop="personName">
|
||||
<el-form-item label="姓名" prop="person_name">
|
||||
<el-input v-model="form.person_name" style="width: 35%" />
|
||||
<span style="color: #C0C0C0;margin-left: 10px;">用户姓名不作为登录使用</span>
|
||||
</el-form-item>
|
||||
@@ -64,7 +64,7 @@
|
||||
<el-tab-pane label="操作日志" name="second">
|
||||
<el-table v-loading="loading" :data="data" style="width: 100%;">
|
||||
<el-table-column prop="description" label="行为" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="requestIp" label="IP" />
|
||||
<el-table-column prop="request_ip" label="IP" />
|
||||
<el-table-column show-overflow-tooltip prop="address" label="IP来源" />
|
||||
<el-table-column prop="browser" label="浏览器" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="time" label="请求耗时" align="center">
|
||||
@@ -83,7 +83,7 @@
|
||||
<div style="display:inline-block;float: right;cursor: pointer" @click="init">创建日期<i class="el-icon-refresh" style="margin-left: 40px" /></div>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
<span>{{ parseTime(scope.row.create_time) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -116,7 +116,7 @@ import store from '@/store'
|
||||
import { isvalidPhone } from '@/utils/validate'
|
||||
import { parseTime } from '@/utils/index'
|
||||
import crud from '@/mixins/crud'
|
||||
import { editUser } from '@/views/system/user'
|
||||
import { editUser } from '@/views/system/user/user'
|
||||
import Avatar from '@/assets/images/avatar.png'
|
||||
export default {
|
||||
name: 'Center',
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
},
|
||||
form: {},
|
||||
rules: {
|
||||
personName: [
|
||||
person_name: [
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
@@ -161,7 +161,7 @@ export default {
|
||||
])
|
||||
},
|
||||
created() {
|
||||
this.form = { id: this.user.id, personName: this.user.personName, gender: this.user.gender, phone: this.user.phone }
|
||||
this.form = { id: this.user.id, person_name: this.user.person_name, gender: this.user.gender, phone: this.user.phone }
|
||||
store.dispatch('GetInfo').then(() => {})
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<script>
|
||||
import store from '@/store'
|
||||
import { updatePass } from '@/views/system/user'
|
||||
import { updatePass } from '@/views/system/user/user'
|
||||
export default {
|
||||
data() {
|
||||
const confirmPass = (rule, value, callback) => {
|
||||
|
||||
Reference in New Issue
Block a user