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("消息发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user