refactor: 通知公告重构完成
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 通知类型枚举
|
||||
* 0-系统消息
|
||||
*
|
||||
* @since 2024-9-1 17:33:06
|
||||
* @author Theo
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum NoticeTypeEnum implements IBaseEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
SYSTEM_MESSAGE(0, "系统消息");
|
||||
|
||||
@Getter
|
||||
private Integer value;
|
||||
|
||||
@Getter
|
||||
private String label;
|
||||
|
||||
NoticeTypeEnum(Integer value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 通知方式枚举
|
||||
* @author Theo
|
||||
* @since 2024-9-2 14:32:58
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum NoticeWayEnum implements IBaseEnum<String> {
|
||||
/**
|
||||
* 通知方式
|
||||
*/
|
||||
WEBSOCKET("webSocket", "发送websocket消息");
|
||||
|
||||
@Getter
|
||||
private String value;
|
||||
|
||||
@Getter
|
||||
private String label;
|
||||
|
||||
NoticeWayEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,16 @@ import lombok.Getter;
|
||||
* @author haoxr
|
||||
* @since 2022/10/14
|
||||
*/
|
||||
@Getter
|
||||
public enum StatusEnum implements IBaseEnum<Integer> {
|
||||
|
||||
ENABLE(1, "启用"),
|
||||
DISABLE (0, "禁用");
|
||||
|
||||
@Getter
|
||||
private Integer value;
|
||||
private final Integer value;
|
||||
|
||||
@Getter
|
||||
private String label;
|
||||
|
||||
private final String label;
|
||||
|
||||
StatusEnum(Integer value, String label) {
|
||||
this.value = value;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.youlai.boot.common.util;
|
||||
|
||||
import com.youlai.boot.common.constant.SymbolConstant;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通用工具类
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-9-1 23:42:33
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class CommonUtil {
|
||||
|
||||
private CommonUtil(){}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将List转换为字符串
|
||||
*
|
||||
* @param list List
|
||||
* @param separator 分隔符
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String listToStr(List<String> list, String separator) {
|
||||
if(list == null || list.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
return list.stream().collect(Collectors.joining(separator));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换为List
|
||||
*
|
||||
* @param list List
|
||||
* @return List
|
||||
*/
|
||||
public static String listToStr(List<String> list) {
|
||||
return listToStr(list, SymbolConstant.COMMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换为List
|
||||
*
|
||||
* @param str 字符串
|
||||
* @return List
|
||||
*/
|
||||
public static List<String> strToList(String str) {
|
||||
return strToList(str, SymbolConstant.COMMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换为List
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param separator 分隔符
|
||||
* @return List
|
||||
*/
|
||||
public static List<String> strToList(String str, String separator) {
|
||||
return List.of(str.split(separator));
|
||||
}
|
||||
|
||||
|
||||
public static String delHtmlTags(String htmlStr) {
|
||||
return htmlStr.replaceAll("<[^>]+>", "");
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.youlai.boot.module.auth.controller;
|
||||
|
||||
import com.youlai.boot.common.constant.RedisConstants;
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.module.auth.service.AuthService;
|
||||
import com.youlai.boot.system.model.dto.CaptchaResult;
|
||||
import com.youlai.boot.system.model.dto.LoginResult;
|
||||
import com.youlai.boot.common.annotation.Log;
|
||||
import com.youlai.boot.system.service.ConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.module.auth.enums;
|
||||
|
||||
/**
|
||||
* EasyCaptcha 验证码类型枚举
|
||||
@@ -9,7 +9,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.jwt.JWTPayload;
|
||||
import cn.hutool.jwt.JWTUtil;
|
||||
import com.youlai.boot.common.constant.SecurityConstants;
|
||||
import com.youlai.boot.common.enums.CaptchaTypeEnum;
|
||||
import com.youlai.boot.module.auth.enums.CaptchaTypeEnum;
|
||||
import com.youlai.boot.module.auth.service.AuthService;
|
||||
import com.youlai.boot.system.model.dto.CaptchaResult;
|
||||
import com.youlai.boot.system.model.dto.LoginResult;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.module.codegen.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.module.codegen.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.module.codegen.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.youlai.boot.common.base.BaseEntity;
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.FormTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.QueryTypeEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.module.codegen.model.form;
|
||||
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.FormTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.QueryTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -10,12 +10,11 @@ import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.common.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.config.property.CodegenProperties;
|
||||
import com.youlai.boot.module.codegen.service.GenConfigService;
|
||||
import com.youlai.boot.module.codegen.service.GenFieldConfigService;
|
||||
import com.youlai.boot.module.codegen.service.CodegenService;
|
||||
import com.youlai.boot.module.codegen.converter.CodegenConverter;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.module.codegen.mapper.DatabaseMapper;
|
||||
import com.youlai.boot.module.codegen.model.entity.GenConfig;
|
||||
@@ -23,10 +22,8 @@ import com.youlai.boot.module.codegen.model.entity.GenFieldConfig;
|
||||
import com.youlai.boot.module.codegen.model.query.TablePageQuery;
|
||||
import com.youlai.boot.module.codegen.model.vo.CodegenPreviewVO;
|
||||
import com.youlai.boot.module.codegen.model.vo.TablePageVO;
|
||||
import com.youlai.boot.system.service.MenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -224,7 +221,7 @@ public class CodegenServiceImpl implements CodegenService {
|
||||
bindMap.put("tableName", genConfig.getTableName());
|
||||
bindMap.put("author", genConfig.getAuthor());
|
||||
bindMap.put("lowerFirstEntityName", StrUtil.lowerFirst(entityName)); // UserTest → userTest
|
||||
bindMap.put("kebabCaseEntityName", StrUtil.toSymbolCase(entityName, '-')); // UserTest → user-test
|
||||
bindMap.put("kebabCaseEntityName", StrUtil.toSymbolCase(entityName, '-')); // UserTest → user-websocket
|
||||
bindMap.put("businessName", genConfig.getBusinessName());
|
||||
bindMap.put("fieldConfigs", fieldConfigs);
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.YouLaiApplication;
|
||||
import com.youlai.boot.common.enums.EnvEnum;
|
||||
import com.youlai.boot.common.enums.FormTypeEnum;
|
||||
import com.youlai.boot.common.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.common.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.FormTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.JavaTypeEnum;
|
||||
import com.youlai.boot.module.codegen.enums.QueryTypeEnum;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.config.property.CodegenProperties;
|
||||
import com.youlai.boot.module.codegen.converter.CodegenConverter;
|
||||
|
||||
@@ -138,10 +138,10 @@ public class MinioFileService implements FileService {
|
||||
try {
|
||||
String fileName;
|
||||
if (StrUtil.isNotBlank(customDomain)) {
|
||||
// https://oss.youlai.tech/default/20221120/test.jpg → 20221120/test.jpg
|
||||
// https://oss.youlai.tech/default/20221120/test.jpg → 20221120/websocket.jpg
|
||||
fileName = filePath.substring(customDomain.length() + 1 + bucketName.length() + 1); // 两个/占了2个字符长度
|
||||
} else {
|
||||
// http://localhost:9000/default/20221120/test.jpg → 20221120/test.jpg
|
||||
// http://localhost:9000/default/20221120/test.jpg → 20221120/websocket.jpg
|
||||
fileName = filePath.substring(endpoint.length() + 1 + bucketName.length() + 1);
|
||||
}
|
||||
RemoveObjectArgs removeObjectArgs = RemoveObjectArgs.builder()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.youlai.boot.module.websocket.controller;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
import com.youlai.boot.system.model.dto.ChatMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -14,7 +13,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.security.Principal;
|
||||
|
||||
/**
|
||||
* WebSocket 测试控制层
|
||||
* WebSocket 测试用例控制层
|
||||
* <p>
|
||||
* 包含点对点/广播发送消息
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2.3.0
|
||||
@@ -28,7 +29,6 @@ public class WebsocketController {
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 广播发送消息
|
||||
*
|
||||
@@ -58,7 +58,7 @@ public class WebsocketController {
|
||||
|
||||
log.info("发送人:{}; 接收人:{}", sender, receiver);
|
||||
// 发送消息给指定用户,拼接后路径 /user/{receiver}/queue/greeting
|
||||
messagingTemplate.convertAndSendToUser(receiver, "/queue/greeting", new ChatMessage(sender, message, NoticeTypeEnum.SYSTEM_MESSAGE));
|
||||
messagingTemplate.convertAndSendToUser(receiver, "/queue/greeting", new ChatMessage(sender, message));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.youlai.boot.module.websocket.listener;
|
||||
|
||||
import com.youlai.boot.module.websocket.service.OnlineUserService;
|
||||
import com.youlai.boot.system.event.UserConnectionEvent;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 在线用户监听器
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2024/9/25
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class OnlineUserListener {
|
||||
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
private final OnlineUserService onlineUserService;
|
||||
|
||||
/**
|
||||
* 用户连接事件处理
|
||||
*
|
||||
* @param event 用户连接事件
|
||||
*/
|
||||
@EventListener
|
||||
public void handleUserConnectionEvent(UserConnectionEvent event) {
|
||||
String username = event.getUsername();
|
||||
if (event.isConnected()) {
|
||||
onlineUserService.addOnlineUser(username);
|
||||
log.info("User connected: {}", username);
|
||||
} else {
|
||||
onlineUserService.removeOnlineUser(username);
|
||||
log.info("User disconnected: {}", username);
|
||||
}
|
||||
// 推送在线用户人数
|
||||
messagingTemplate.convertAndSend("/topic/onlineUserCount", onlineUserService.getOnlineUserCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.youlai.boot.module.websocket.service;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import com.youlai.boot.system.model.dto.MessageDTO;
|
||||
|
||||
/**
|
||||
* 消息服务接口
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-9-2 14:32:58
|
||||
*/
|
||||
public interface MessageService {
|
||||
|
||||
|
||||
/**
|
||||
* 检查消息类型
|
||||
*
|
||||
* @param messageType 消息类型
|
||||
* @return 是否支持
|
||||
*/
|
||||
boolean check(NoticeWayEnum messageType);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
void sendMessage(MessageDTO message);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.youlai.boot.module.websocket.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 在线用户服务
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2024/9/26
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class OnlineUserService {
|
||||
|
||||
private final Set<String> onlineUsers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
/**
|
||||
* 添加用户到在线用户集合
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
public void addOnlineUser(String username) {
|
||||
onlineUsers.add(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从在线用户集合移除用户
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
public void removeOnlineUser(String username) {
|
||||
onlineUsers.remove(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有在线用户
|
||||
*
|
||||
* @return 在线用户集合
|
||||
*/
|
||||
public Set<String> getAllOnlineUsers() {
|
||||
return Collections.unmodifiableSet(onlineUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线的接收者
|
||||
* 从所有接收者中过滤出在线的接收者
|
||||
*
|
||||
* @param receivers 接收者
|
||||
* @return 在线的接收者集合
|
||||
*/
|
||||
public Set<String> getOnlineReceivers(Set<String> receivers) {
|
||||
return receivers.stream().filter(onlineUsers::contains).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线用户数量
|
||||
*
|
||||
* @return 在线用户数量
|
||||
*/
|
||||
public int getOnlineUserCount() {
|
||||
return onlineUsers.size();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.youlai.boot.module.websocket.service.impl;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
import com.youlai.boot.module.websocket.service.MessageService;
|
||||
import com.youlai.boot.system.event.UserConnectionEvent;
|
||||
import com.youlai.boot.system.model.dto.ChatMessage;
|
||||
import com.youlai.boot.system.model.dto.MessageDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* WebSocket消息服务实现类
|
||||
*
|
||||
* @author ray
|
||||
* @since 2024-9-2 14:32:58
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class WebsocketServiceImpl implements MessageService {
|
||||
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
private final Set<String> onlineUsers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
/**
|
||||
* 用户连接事件处理
|
||||
*
|
||||
* @param event 用户连接事件
|
||||
*/
|
||||
@EventListener
|
||||
public void handleUserConnectionEvent(UserConnectionEvent event) {
|
||||
String username = event.getUsername();
|
||||
if (event.isConnected()) {
|
||||
onlineUsers.add(username);
|
||||
log.info("User connected: {}", username);
|
||||
} else {
|
||||
onlineUsers.remove(username);
|
||||
log.info("User disconnected: {}", username);
|
||||
}
|
||||
// 推送在线用户人数
|
||||
messagingTemplate.convertAndSend("/topic/onlineUserCount", onlineUsers.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时推送在线用户人数
|
||||
*/
|
||||
@Scheduled(fixedRate = 5000)
|
||||
public void sendOnlineUserCount() {
|
||||
messagingTemplate.convertAndSend("/topic/onlineUserCount", onlineUsers.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 策略模式检查
|
||||
*
|
||||
* @param noticeWayEnum 通知方式
|
||||
* @return boolean 是否支持
|
||||
*/
|
||||
@Override
|
||||
public boolean check(NoticeWayEnum noticeWayEnum) {
|
||||
return noticeWayEnum.equals(NoticeWayEnum.WEBSOCKET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(MessageDTO message) {
|
||||
List<String> users = null;
|
||||
if(message.getReceiver() == null || message.getReceiver().isEmpty()){
|
||||
// 发送给所有在线用户 离线用户不发送,因为离线用户下次登录会直接查询未读消息
|
||||
users = new ArrayList<>(onlineUsers);
|
||||
}else{
|
||||
users = message.getReceiver().stream().filter(onlineUsers::contains).collect(Collectors.toList());
|
||||
}
|
||||
//获取当前用户
|
||||
ChatMessage chatMessage = new ChatMessage(message.getSender(), message.getContent(), NoticeTypeEnum.SYSTEM_MESSAGE);
|
||||
users.forEach(receiver -> {
|
||||
messagingTemplate.convertAndSendToUser(receiver, "/queue/message", chatMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.boot.common.result.PageResult;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.system.model.form.NoticeForm;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserUnreadNoticeVO;
|
||||
import com.youlai.boot.system.service.NoticeService;
|
||||
import com.youlai.boot.system.service.NoticeStatusService;
|
||||
import com.youlai.boot.system.service.UserNoticeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -18,6 +20,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知公告前端控制层
|
||||
*
|
||||
@@ -28,47 +32,51 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/notices")
|
||||
@RequiredArgsConstructor
|
||||
public class NoticeController {
|
||||
public class NoticeController {
|
||||
|
||||
private final NoticeService noticeService;
|
||||
private final NoticeStatusService noticeStatusService;
|
||||
|
||||
private final UserNoticeService userNoticeService;
|
||||
|
||||
@Operation(summary = "通知公告分页列表")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:query')")
|
||||
public PageResult<NoticeVO> getNoticePage(NoticeQuery queryParams ) {
|
||||
IPage<NoticeVO> result = noticeService.getNoticePage(queryParams);
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:query')")
|
||||
public PageResult<NoticePageVO> getNoticePage(NoticePageQuery queryParams) {
|
||||
IPage<NoticePageVO> result = noticeService.getNoticePage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增通知公告")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:add')")
|
||||
public Result<?> saveNotice(@RequestBody @Valid NoticeForm formData ) {
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:add')")
|
||||
public Result<?> saveNotice(@RequestBody @Valid NoticeForm formData) {
|
||||
boolean result = noticeService.saveNotice(formData);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取通知公告表单数据")
|
||||
@GetMapping("/{id}/form")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:edit')")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:edit')")
|
||||
public Result<NoticeForm> getNoticeForm(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
NoticeForm formData = noticeService.getNoticeFormData(id);
|
||||
return Result.success(formData);
|
||||
}
|
||||
@Operation(summary = "管理页面查看通知公告")
|
||||
@GetMapping("/detail/{id}")
|
||||
public Result<?> getReadNoticeDetail(
|
||||
@Parameter(description = "通知公告ID")@PathVariable Long id) {
|
||||
return Result.success(noticeService.getReadNoticeDetail(id));
|
||||
|
||||
@Operation(summary = "阅读获取通知公告详情")
|
||||
@GetMapping("/{id}/detail")
|
||||
public Result<NoticeDetailVO> getNoticeDetail(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
NoticeDetailVO detailVO = noticeService.getNoticeDetail(id);
|
||||
return Result.success(detailVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改通知公告")
|
||||
@PutMapping(value = "/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:edit')")
|
||||
public Result<?> updateNotice(
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:edit')")
|
||||
public Result<Void> updateNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id,
|
||||
@RequestBody @Validated NoticeForm formData
|
||||
) {
|
||||
@@ -77,26 +85,30 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
@Operation(summary = "发布通知公告")
|
||||
@PatchMapping(value = "/release/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:release')")
|
||||
public Result<?> releaseNotice(@Parameter(description = "通知公告ID") @PathVariable Long id) {
|
||||
boolean result = noticeService.releaseNotice(id);
|
||||
@PatchMapping(value = "/{id}/publish")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:publish')")
|
||||
public Result<Void> publishNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
boolean result = noticeService.publishNotice(id);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "撤回通知公告")
|
||||
@PatchMapping(value = "/recall/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:recall')")
|
||||
public Result<?> recallNotice(@Parameter(description = "通知公告ID") @PathVariable Long id) {
|
||||
boolean result = noticeService.recallNotice(id);
|
||||
@PatchMapping(value = "/{id}/revoke")
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:revoke')")
|
||||
public Result<Void> revokeNotice(
|
||||
@Parameter(description = "通知公告ID") @PathVariable Long id
|
||||
) {
|
||||
boolean result = noticeService.revokeNotice(id);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除通知公告")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@ss.hasPerm('system:notice:delete')")
|
||||
public Result<?> deleteNotices(
|
||||
@Parameter(description = "通知公告ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
@PreAuthorize("@ss.hasPerm('sys:notice:delete')")
|
||||
public Result<Void> deleteNotices(
|
||||
@Parameter(description = "通知公告ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
) {
|
||||
boolean result = noticeService.deleteNotices(ids);
|
||||
return Result.judge(result);
|
||||
@@ -104,27 +116,24 @@ public class NoticeController {
|
||||
|
||||
@Operation(summary = "获取未读的通知公告")
|
||||
@GetMapping("/unread")
|
||||
public Result<?> listUnreadNotices() {
|
||||
return Result.success(noticeStatusService.listUnreadNotices());
|
||||
}
|
||||
|
||||
@Operation(summary = "阅读通知公告")
|
||||
@PatchMapping("/read/{id}")
|
||||
public Result<?> readNotice(@PathVariable Long id) {
|
||||
return Result.success(noticeService.readNotice(id));
|
||||
public Result<List<UserUnreadNoticeVO>> listUnreadNotices() {
|
||||
List<UserUnreadNoticeVO> list = userNoticeService.listUnreadNotices();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "全部已读")
|
||||
@PatchMapping("/readAll")
|
||||
public Result<?> readAll() {
|
||||
noticeStatusService.readAll();
|
||||
@PutMapping("/read-all")
|
||||
public Result<Void> readAll() {
|
||||
userNoticeService.readAll();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取我的通知公告")
|
||||
@Operation(summary = "获取我的通知公告分页列表")
|
||||
@GetMapping("/my/page")
|
||||
public PageResult<NoticeStatusVO> getMyNoticePage(NoticeQuery queryParams) {
|
||||
IPage<NoticeStatusVO> result = noticeService.getMyNoticePage(queryParams);
|
||||
public PageResult<UserNoticePageVO> getMyNoticePage(
|
||||
NoticePageQuery queryParams
|
||||
) {
|
||||
IPage<UserNoticePageVO> result = noticeService.getMyNoticePage(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.boot.common.annotation.Log;
|
||||
import com.youlai.boot.common.annotation.RepeatSubmit;
|
||||
import com.youlai.boot.common.enums.ContactType;
|
||||
import com.youlai.boot.system.enums.ContactType;
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.common.result.PageResult;
|
||||
|
||||
@@ -4,7 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.system.model.bo.NoticeBO;
|
||||
import com.youlai.boot.system.model.entity.Notice;
|
||||
import com.youlai.boot.system.model.form.NoticeForm;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
@@ -18,22 +19,20 @@ import org.mapstruct.Mappings;
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface NoticeConverter{
|
||||
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "tarIds", expression = "java(com.youlai.boot.common.util.CommonUtil.strToList(entity.getTarIds()))")
|
||||
@Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.util.StrUtil.split(entity.getTargetUserIds(),\",\"))")
|
||||
})
|
||||
NoticeForm toForm(Notice entity);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "tarIds", expression = "java(com.youlai.boot.common.util.CommonUtil.listToStr(formData.getTarIds()))")
|
||||
@Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.collection.CollUtil.join(formData.getTargetUserIds(),\",\"))")
|
||||
})
|
||||
Notice toEntity(NoticeForm formData);
|
||||
|
||||
NoticeVO toVO(Notice notice);
|
||||
NoticePageVO toPageVo(NoticeBO bo);
|
||||
|
||||
Page<NoticeVO> toPageVo(Page<NoticeBO> noticePage);
|
||||
|
||||
@Mappings({
|
||||
})
|
||||
NoticeVO toPageVo(NoticeBO bo);
|
||||
Page<NoticePageVO> toPageVo(Page<NoticeBO> noticePage);
|
||||
|
||||
NoticeDetailVO toDetailVO(NoticeBO noticeBO);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.mapstruct.Mappings;
|
||||
public interface UserConverter {
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "genderLabel", expression = "java(com.youlai.boot.common.base.IBaseEnum.getLabelByValue(bo.getGender(), com.youlai.boot.common.enums.GenderEnum.class))")
|
||||
@Mapping(target = "genderLabel", expression = "java(com.youlai.boot.common.base.IBaseEnum.getLabelByValue(bo.getGender(), com.youlai.boot.system.enums.GenderEnum.class))")
|
||||
})
|
||||
UserPageVO toPageVo(UserBO bo);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
/**
|
||||
* 联系方式类型
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.youlai.boot.common.enums;
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 通告发布状态枚举
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/10/14
|
||||
*/
|
||||
@Getter
|
||||
@Schema(enumAsRef = true)
|
||||
public enum NoticePublishStatusEnum implements IBaseEnum<Integer> {
|
||||
|
||||
UNPUBLISHED(0, "未发布"),
|
||||
PUBLISHED(1, "已发布"),
|
||||
REVOKED(-1, "已撤回");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final String label;
|
||||
|
||||
NoticePublishStatusEnum(Integer value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.youlai.boot.system.enums;
|
||||
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 通知目标类型枚举
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/10/14
|
||||
*/
|
||||
@Getter
|
||||
@Schema(enumAsRef = true)
|
||||
public enum NoticeTargetTypeEnum implements IBaseEnum<Integer> {
|
||||
|
||||
ALL(1, "全体"),
|
||||
SPECIFIED(2, "指定");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final String label;
|
||||
|
||||
NoticeTargetTypeEnum(Integer value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.youlai.boot.system.handler;
|
||||
|
||||
import com.youlai.boot.module.websocket.service.MessageService;
|
||||
import com.youlai.boot.system.model.dto.MessageDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息处理器
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-9-2 14:32:58
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MessageHandler {
|
||||
|
||||
private final List<MessageService> messageServices;
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* 如果后面有多种消息发送方式,可以设置MessageDTO中的noticeWay,调用不同的消息发送方式,实现消息多种发送方式
|
||||
* @param messageDTO 消息载体
|
||||
*/
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
messageServices.forEach(messageService -> {
|
||||
if (messageService.check(messageDTO.getNoticeWay())) {
|
||||
messageService.sendMessage(messageDTO);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,13 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.youlai.boot.common.base.BaseAnalysisEventListener;
|
||||
import com.youlai.boot.system.enums.GenderEnum;
|
||||
import com.youlai.boot.system.model.entity.Dept;
|
||||
import com.youlai.boot.system.model.entity.Role;
|
||||
import com.youlai.boot.system.model.entity.User;
|
||||
import com.youlai.boot.system.model.entity.UserRole;
|
||||
import com.youlai.boot.common.base.IBaseEnum;
|
||||
import com.youlai.boot.common.constant.SystemConstants;
|
||||
import com.youlai.boot.common.enums.GenderEnum;
|
||||
import com.youlai.boot.common.enums.StatusEnum;
|
||||
import com.youlai.boot.system.converter.UserConverter;
|
||||
import com.youlai.boot.system.model.dto.UserImportDTO;
|
||||
@@ -107,13 +107,12 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
// 校验通过,持久化至数据库
|
||||
User entity = userConverter.toEntity(userImportDTO);
|
||||
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
|
||||
// 性别翻译
|
||||
// 性别逆向解析
|
||||
String genderLabel = userImportDTO.getGenderLabel();
|
||||
if (StrUtil.isNotBlank(genderLabel)) {
|
||||
Integer genderValue = (Integer) IBaseEnum.getValueByLabel(genderLabel, GenderEnum.class);
|
||||
entity.setGender(genderValue);
|
||||
}
|
||||
|
||||
// 角色解析
|
||||
String roleCodes = userImportDTO.getRoleCodes();
|
||||
List<Long> roleIds = null;
|
||||
@@ -155,7 +154,7 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
}
|
||||
} else {
|
||||
invalidCount++;
|
||||
msg.append("第").append(validCount + invalidCount).append("行数据校验失败:").append(validationMsg + "<br/>");
|
||||
msg.append("第").append(validCount + invalidCount).append("行数据校验失败:").append(validationMsg).append("<br/>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +165,6 @@ public class UserImportListener extends BaseAnalysisEventListener<UserImportDTO>
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
log.info("所有数据解析完成!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.system.model.bo.NoticeBO;
|
||||
import com.youlai.boot.system.model.entity.Notice;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -26,12 +25,13 @@ public interface NoticeMapper extends BaseMapper<Notice> {
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页数据
|
||||
*/
|
||||
Page<NoticeBO> getNoticePage(Page<NoticeVO> page, @Param("queryParams") NoticeQuery queryParams);
|
||||
Page<NoticeBO> getNoticePage(Page<NoticePageVO> page, NoticePageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取阅读时通知公告详情
|
||||
*
|
||||
* @param id 通知公告ID
|
||||
* @return 通知公告详情
|
||||
*/
|
||||
NoticeDetailVO getReadNoticeVO(@Param("id") Long id);
|
||||
NoticeBO getNoticeDetail(@Param("id") Long id);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package com.youlai.boot.system.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.boot.system.model.entity.NoticeStatus;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.entity.UserNotice;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserUnreadNoticeVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -19,14 +20,14 @@ import java.util.List;
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeStatusMapper extends BaseMapper<NoticeStatus> {
|
||||
public interface UserNoticeMapper extends BaseMapper<UserNotice> {
|
||||
|
||||
/**
|
||||
* 获取未读的通知公告
|
||||
* @param userId 用户ID
|
||||
* @return 公告列表
|
||||
*/
|
||||
List<NoticeStatusVO> listUnreadNotices(@Param("userId")Long userId);
|
||||
List<UserUnreadNoticeVO> listUnreadNotices(Long userId);
|
||||
|
||||
/**
|
||||
* 分页获取我的通知公告
|
||||
@@ -34,5 +35,5 @@ public interface NoticeStatusMapper extends BaseMapper<NoticeStatus> {
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
IPage<NoticeStatusVO> getMyNoticePage(Page<NoticeVO> page, @Param("queryParams") NoticeQuery queryParams);
|
||||
IPage<UserNoticePageVO> getMyNoticePage(Page<NoticePageVO> page, @Param("queryParams") NoticePageQuery queryParams);
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.youlai.boot.system.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -11,36 +9,72 @@ import java.time.LocalDateTime;
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-09-01 10:31
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class NoticeBO {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 通知ID
|
||||
*/
|
||||
private Long id;
|
||||
@Schema(description = "通知标题")
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "发布人")
|
||||
private String releaseBy;
|
||||
/**
|
||||
* 通知类型标签
|
||||
*/
|
||||
private String typeLabel;
|
||||
|
||||
@Schema(description = "优先级(0-低 1-中 2-高)")
|
||||
private Integer priority;
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
@Schema(description = "目标类型(0-全体 1-指定)")
|
||||
private Integer tarType;
|
||||
/**
|
||||
* 发布人姓名
|
||||
*/
|
||||
private String publisherName;
|
||||
|
||||
@Schema(description = "发布状态(0-未发布 1已发布 2已撤回)")
|
||||
private Integer releaseStatus;
|
||||
/**
|
||||
* 通知等级(L: 低, M: 中, H: 高)
|
||||
*/
|
||||
private String level;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
private LocalDateTime releaseTime;
|
||||
/**
|
||||
* 通知等级标签
|
||||
*/
|
||||
private String levelLabel;
|
||||
|
||||
@Schema(description = "撤回时间")
|
||||
private LocalDateTime recallTime;
|
||||
/**
|
||||
* 目标类型(1: 全体 2: 指定)
|
||||
*/
|
||||
private Integer targetType;
|
||||
|
||||
/**
|
||||
* 发布状态(0: 未发布, 1: 已发布, -1: 已撤回)
|
||||
*/
|
||||
private Integer publishStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 撤回时间
|
||||
*/
|
||||
private LocalDateTime revokeTime;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.youlai.boot.system.model.bo;
|
||||
|
||||
import com.youlai.boot.common.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.system.enums.MenuTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.youlai.boot.system.model.dto;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -23,9 +22,4 @@ public class ChatMessage {
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private NoticeTypeEnum noticeType;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.youlai.boot.system.model.dto;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 消息载体
|
||||
@@ -23,8 +22,8 @@ public class MessageDTO {
|
||||
private String sender;
|
||||
|
||||
@Schema(description = "接收者")
|
||||
private List<String> receiver;
|
||||
private Set<String> receivers;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "通知方式")
|
||||
private NoticeWayEnum noticeWay;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.youlai.boot.system.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 通知传送对象
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-9-2 14:32:58
|
||||
*/
|
||||
@Data
|
||||
public class NoticeDTO {
|
||||
|
||||
@Schema(description = "通知ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.youlai.boot.system.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import com.youlai.boot.common.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.system.enums.MenuTypeEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.youlai.boot.system.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.youlai.boot.common.base.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* 通知公告实体对象
|
||||
@@ -19,6 +19,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("sys_notice")
|
||||
public class Notice extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -32,41 +33,48 @@ public class Notice extends BaseEntity {
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer noticeType;
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
private Long releaseBy;
|
||||
private Long publisherId;
|
||||
|
||||
/**
|
||||
* 优先级(0-低 1-中 2-高)
|
||||
* 通知等级(L: 低, M: 中, H: 高)
|
||||
*/
|
||||
private Integer priority;
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 目标类型(0-全体 1-指定)
|
||||
* 目标类型(1: 全体, 2: 指定)
|
||||
*/
|
||||
private Integer tarType;
|
||||
private Integer targetType;
|
||||
|
||||
/**
|
||||
* 目标ID
|
||||
* 目标用户ID集合
|
||||
*/
|
||||
private String tarIds;
|
||||
private String targetUserIds;
|
||||
|
||||
/**
|
||||
* 发布状态(0-未发布 1已发布 2已撤回)
|
||||
* 发布状态(0: 未发布, 1: 已发布, -1: 已撤回)
|
||||
*/
|
||||
private Integer releaseStatus;
|
||||
private Integer publishStatus;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime releaseTime;
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
/**
|
||||
* 撤回时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime recallTime;
|
||||
private LocalDateTime revokeTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
|
||||
@@ -2,25 +2,24 @@ package com.youlai.boot.system.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.youlai.boot.common.base.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户公告状态实体对象
|
||||
* 用户通知公告实体对象
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_notice_status")
|
||||
public class NoticeStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableName("sys_user_notice")
|
||||
public class UserNotice extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
@@ -39,9 +38,15 @@ public class NoticeStatus implements Serializable {
|
||||
/**
|
||||
* 读取状态,0未读,1已读
|
||||
*/
|
||||
private Integer readStatus;
|
||||
private Integer isRead;
|
||||
/**
|
||||
* 用户阅读时间
|
||||
*/
|
||||
private LocalDateTime readTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识(0-未删除 1-已删除)
|
||||
*/
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer isDeleted;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.youlai.boot.system.model.form;
|
||||
|
||||
import com.youlai.boot.common.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.system.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.common.model.KeyValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -39,17 +39,16 @@ public class NoticeForm implements Serializable {
|
||||
private String content;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "优先级(0-低 1-中 2-高)")
|
||||
@Range(min = 0, max = 2, message = "优先级取值范围[0,2]")
|
||||
private Integer priority;
|
||||
@Schema(description = "优先级(L-低 M-中 H-高)")
|
||||
private String level;
|
||||
|
||||
@Schema(description = "目标类型(0-全体 1-指定)")
|
||||
@Range(min = 0, max = 1, message = "目标类型取值范围[0,1]")
|
||||
private Integer tarType;
|
||||
@Schema(description = "目标类型(1-全体 2-指定)")
|
||||
@Range(min = 1, max = 2, message = "目标类型取值范围[1,2]")
|
||||
private Integer targetType;
|
||||
|
||||
@Schema(description = "接收人ID集合")
|
||||
private List<String> tarIds;
|
||||
private List<String> targetUserIds;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,19 +16,21 @@ import java.util.List;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description ="通知公告查询对象")
|
||||
public class NoticeQuery extends BasePageQuery {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class NoticePageQuery extends BasePageQuery {
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "发布状态(0-未发布 1已发布 2已撤回)")
|
||||
private Integer releaseStatus;
|
||||
@Schema(description = "发布状态(0-未发布 1已发布 -1已撤回)")
|
||||
private Integer publishStatus;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
private List<String> releaseTime;
|
||||
@Schema(description = "发布时间(起止)")
|
||||
private List<String> publishTime;
|
||||
|
||||
@Schema(description = "查询人ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "是否已读(0-未读 1-已读)")
|
||||
private Integer isRead;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.youlai.boot.common.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.system.enums.MenuTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ public class NoticeDetailVO {
|
||||
private String content;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private String noticeType;
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "发布人")
|
||||
private String releaseBy;
|
||||
private String publisherName;
|
||||
|
||||
@Schema(description = "优先级(0-低 1-中 2-高)")
|
||||
private Integer priority;
|
||||
@Schema(description = "优先级(L-低 M-中 H-高)")
|
||||
private String level;
|
||||
|
||||
@Schema(description = "发布状态(0-未发布 1已发布 2已撤回) 冗余字段,方便判断是否已经发布")
|
||||
private Integer releaseStatus;
|
||||
private Integer publishStatus;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime releaseTime;
|
||||
private LocalDateTime publishTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通知公告视图对象
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-27 10:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "通知公告视图对象")
|
||||
public class NoticePageVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "通知ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知状态")
|
||||
private Integer publishStatus;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private String typeLabel;
|
||||
|
||||
@Schema(description = "发布人姓名")
|
||||
private String publisherName;
|
||||
|
||||
@Schema(description = "通知等级")
|
||||
private String level;
|
||||
|
||||
@Schema(description = "通知等级")
|
||||
private String levelLabel;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@Schema(description = "是否已读")
|
||||
private Integer isRead;
|
||||
|
||||
@Schema(description = "目标类型")
|
||||
private Integer targetType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "撤回时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private LocalDateTime revokeTime;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通知公告视图对象
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-27 10:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema( description = "通知公告视图对象")
|
||||
public class NoticeVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private String noticeType;
|
||||
|
||||
@Schema(description = "发布人")
|
||||
private String releaseBy;
|
||||
|
||||
@Schema(description = "优先级(0-低 1-中 2-高)")
|
||||
private Integer priority;
|
||||
|
||||
@Schema(description = "目标类型(0-全体 1-指定)")
|
||||
private Integer tarType;
|
||||
|
||||
@Schema(description = "发布状态(0-未发布 1已发布 2已撤回)")
|
||||
private Integer releaseStatus;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime releaseTime;
|
||||
|
||||
@Schema(description = "撤回时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime recallTime;
|
||||
}
|
||||
@@ -7,14 +7,14 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户公告状态VO
|
||||
* 用户公告VO
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户公告状态VO")
|
||||
public class NoticeStatusVO {
|
||||
@Schema(description = "用户公告VO")
|
||||
public class UserNoticePageVO {
|
||||
|
||||
@Schema(description = "通知ID")
|
||||
private Long id;
|
||||
@@ -23,19 +23,19 @@ public class NoticeStatusVO {
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private String noticeType;
|
||||
private String typeLabel;
|
||||
|
||||
@Schema(description = "发布人")
|
||||
private String releaseBy;
|
||||
@Schema(description = "发布人姓名")
|
||||
private String publisherName;
|
||||
|
||||
@Schema(description = "优先级(0-低 1-中 2-高)")
|
||||
private Integer priority;
|
||||
@Schema(description = "通知级别")
|
||||
private String levelLabel;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime releaseTime;
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@Schema(description = "是否已读")
|
||||
private Integer readStatus;
|
||||
private Integer isRead;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户公告VO
|
||||
*
|
||||
* @author Theo
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户公告VO")
|
||||
public class UserUnreadNoticeVO {
|
||||
|
||||
@Schema(description = "通知ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.system.model.entity.Notice;
|
||||
import com.youlai.boot.system.model.form.NoticeForm;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
|
||||
/**
|
||||
@@ -18,11 +18,11 @@ import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
public interface NoticeService extends IService<Notice> {
|
||||
|
||||
/**
|
||||
*通知公告分页列表
|
||||
* 通知公告分页列表
|
||||
*
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
IPage<NoticeVO> getNoticePage(NoticeQuery queryParams);
|
||||
IPage<NoticePageVO> getNoticePage(NoticePageQuery queryParams);
|
||||
|
||||
/**
|
||||
* 获取通知公告表单数据
|
||||
@@ -30,7 +30,7 @@ public interface NoticeService extends IService<Notice> {
|
||||
* @param id 通知公告ID
|
||||
* @return 通知公告表单对象
|
||||
*/
|
||||
NoticeForm getNoticeFormData(Long id);
|
||||
NoticeForm getNoticeFormData(Long id);
|
||||
|
||||
/**
|
||||
* 新增通知公告
|
||||
@@ -43,7 +43,7 @@ public interface NoticeService extends IService<Notice> {
|
||||
/**
|
||||
* 修改通知公告
|
||||
*
|
||||
* @param id 通知公告ID
|
||||
* @param id 通知公告ID
|
||||
* @param formData 通知公告表单对象
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public interface NoticeService extends IService<Notice> {
|
||||
* @param id 通知公告ID
|
||||
* @return 是否发布成功
|
||||
*/
|
||||
boolean releaseNotice(Long id);
|
||||
boolean publishNotice(Long id);
|
||||
|
||||
/**
|
||||
* 撤回通知公告
|
||||
@@ -71,27 +71,21 @@ public interface NoticeService extends IService<Notice> {
|
||||
* @param id 通知公告ID
|
||||
* @return 是否撤回成功
|
||||
*/
|
||||
boolean recallNotice(Long id);
|
||||
boolean revokeNotice(Long id);
|
||||
|
||||
/**
|
||||
* 阅读通知公告
|
||||
* 阅读获取通知公告详情
|
||||
*
|
||||
* @param id 通知公告ID
|
||||
* @return 通知公告对象
|
||||
*/
|
||||
NoticeDetailVO readNotice(Long id);
|
||||
|
||||
/**
|
||||
* 获取阅读时通知公告详情
|
||||
* @param id 通知公告ID
|
||||
* @return 通知公告详情
|
||||
*/
|
||||
NoticeDetailVO getReadNoticeDetail(Long id);
|
||||
NoticeDetailVO getNoticeDetail(Long id);
|
||||
|
||||
/**
|
||||
* 获取我的通知公告分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
IPage<NoticeStatusVO> getMyNoticePage(NoticeQuery queryParams);
|
||||
IPage<UserNoticePageVO> getMyNoticePage(NoticePageQuery queryParams);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package com.youlai.boot.system.service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.system.model.entity.NoticeStatus;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.entity.UserNotice;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserUnreadNoticeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,16 +17,17 @@ import java.util.List;
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
public interface NoticeStatusService extends IService<NoticeStatus> {
|
||||
public interface UserNoticeService extends IService<UserNotice> {
|
||||
|
||||
/**
|
||||
* 获取未读的通知公告
|
||||
* @return 公告列表
|
||||
*/
|
||||
List<NoticeStatusVO> listUnreadNotices();
|
||||
List<UserUnreadNoticeVO> listUnreadNotices();
|
||||
|
||||
/**
|
||||
* 全部标记为已读
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean readAll();
|
||||
@@ -36,5 +38,5 @@ public interface NoticeStatusService extends IService<NoticeStatus> {
|
||||
* @param queryParams 查询参数
|
||||
* @return 我的通知公告分页列表
|
||||
*/
|
||||
IPage<NoticeStatusVO> getMyNoticePage(Page<NoticeVO> page, NoticeQuery queryParams);
|
||||
IPage<UserNoticePageVO> getMyNoticePage(Page<NoticePageVO> page, NoticePageQuery queryParams);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.youlai.boot.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.boot.common.enums.ContactType;
|
||||
import com.youlai.boot.system.enums.ContactType;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.system.model.dto.UserAuthInfo;
|
||||
import com.youlai.boot.system.model.dto.UserExportDTO;
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.youlai.boot.system.model.query.MenuQuery;
|
||||
import com.youlai.boot.system.model.vo.MenuVO;
|
||||
import com.youlai.boot.system.model.vo.RouteVO;
|
||||
import com.youlai.boot.common.constant.SystemConstants;
|
||||
import com.youlai.boot.common.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.system.enums.MenuTypeEnum;
|
||||
import com.youlai.boot.common.enums.StatusEnum;
|
||||
import com.youlai.boot.common.model.KeyValue;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
|
||||
@@ -1,45 +1,48 @@
|
||||
package com.youlai.boot.system.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.common.constant.SymbolConstant;
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import com.youlai.boot.common.exception.BusinessException;
|
||||
import com.youlai.boot.core.security.util.SecurityUtils;
|
||||
import com.youlai.boot.module.websocket.service.OnlineUserService;
|
||||
import com.youlai.boot.system.converter.NoticeConverter;
|
||||
import com.youlai.boot.system.handler.MessageHandler;
|
||||
import com.youlai.boot.system.enums.NoticePublishStatusEnum;
|
||||
import com.youlai.boot.system.enums.NoticeTargetTypeEnum;
|
||||
import com.youlai.boot.system.mapper.NoticeMapper;
|
||||
import com.youlai.boot.system.model.bo.NoticeBO;
|
||||
import com.youlai.boot.system.model.dto.MessageDTO;
|
||||
import com.youlai.boot.system.model.dto.NoticeDTO;
|
||||
import com.youlai.boot.system.model.entity.Notice;
|
||||
import com.youlai.boot.system.model.entity.NoticeStatus;
|
||||
import com.youlai.boot.system.model.entity.UserNotice;
|
||||
import com.youlai.boot.system.model.entity.User;
|
||||
import com.youlai.boot.system.model.form.NoticeForm;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeDetailVO;
|
||||
import com.youlai.boot.system.service.NoticeService;
|
||||
import com.youlai.boot.system.service.NoticeStatusService;
|
||||
import com.youlai.boot.system.service.UserNoticeService;
|
||||
import com.youlai.boot.system.service.UserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通知公告服务实现类
|
||||
*
|
||||
* @author youlaitech
|
||||
* @author Theo
|
||||
* @since 2024-08-27 10:31
|
||||
*/
|
||||
@Service
|
||||
@@ -48,20 +51,21 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
|
||||
private final NoticeConverter noticeConverter;
|
||||
|
||||
private final MessageHandler messageHandler;
|
||||
|
||||
private final NoticeStatusService noticeStatusService;
|
||||
private final UserNoticeService userNoticeService;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
private final OnlineUserService onlineUserService;
|
||||
|
||||
/**
|
||||
* 获取通知公告分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return {@link IPage<NoticeVO>} 通知公告分页列表
|
||||
* @return {@link IPage< NoticePageVO >} 通知公告分页列表
|
||||
*/
|
||||
@Override
|
||||
public IPage<NoticeVO> getNoticePage(NoticeQuery queryParams) {
|
||||
public IPage<NoticePageVO> getNoticePage(NoticePageQuery queryParams) {
|
||||
Page<NoticeBO> noticePage = this.baseMapper.getNoticePage(
|
||||
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||
queryParams
|
||||
@@ -89,12 +93,15 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
*/
|
||||
@Override
|
||||
public boolean saveNotice(NoticeForm formData) {
|
||||
Notice entity = noticeConverter.toEntity(formData);
|
||||
entity.setReleaseStatus(0);
|
||||
entity.setCreateBy(SecurityUtils.getUserId());
|
||||
if (entity.getTarType() == 1) {
|
||||
Assert.notBlank(entity.getTarIds(), "指定用户不能为空");
|
||||
|
||||
if (NoticeTargetTypeEnum.SPECIFIED.getValue().equals(formData.getTargetType())) {
|
||||
List<String> targetUserIdList = formData.getTargetUserIds();
|
||||
if (CollectionUtil.isEmpty(targetUserIdList)) {
|
||||
throw new BusinessException("推送指定用户不能为空");
|
||||
}
|
||||
}
|
||||
Notice entity = noticeConverter.toEntity(formData);
|
||||
entity.setCreateBy(SecurityUtils.getUserId());
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
@@ -107,11 +114,14 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
*/
|
||||
@Override
|
||||
public boolean updateNotice(Long id, NoticeForm formData) {
|
||||
Notice entity = noticeConverter.toEntity(formData);
|
||||
entity.setUpdateBy(SecurityUtils.getUserId());
|
||||
if (entity.getTarType() == 1) {
|
||||
Assert.notBlank(entity.getTarIds(), "指定用户不能为空");
|
||||
if (NoticeTargetTypeEnum.SPECIFIED.getValue().equals(formData.getTargetType())) {
|
||||
List<String> targetUserIdList = formData.getTargetUserIds();
|
||||
if (CollectionUtil.isEmpty(targetUserIdList)) {
|
||||
throw new BusinessException("推送指定用户不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
Notice entity = noticeConverter.toEntity(formData);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@@ -122,87 +132,97 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
* @return {@link Boolean} 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Transactional
|
||||
public boolean deleteNotices(String ids) {
|
||||
Assert.isTrue(StrUtil.isNotBlank(ids), "删除的通知公告数据为空");
|
||||
// 逻辑删除
|
||||
List<Long> idList = Arrays.stream(ids.split(SymbolConstant.COMMA))
|
||||
.map(Long::parseLong)
|
||||
.toList();
|
||||
boolean b = this.removeByIds(idList);
|
||||
if (b) {
|
||||
//删除通知公告的同时,需要删除通知公告对应的用户通知状态
|
||||
noticeStatusService.remove(new LambdaQueryWrapper<NoticeStatus>().in(NoticeStatus::getNoticeId, idList));
|
||||
if (StrUtil.isBlank(ids)) {
|
||||
throw new BusinessException("删除的通知公告数据为空");
|
||||
}
|
||||
|
||||
return true;
|
||||
// 逻辑删除
|
||||
List<Long> idList = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.toList();
|
||||
boolean isRemoved = this.removeByIds(idList);
|
||||
if (isRemoved) {
|
||||
// 删除通知公告的同时,需要删除通知公告对应的用户通知状态
|
||||
userNoticeService.remove(new LambdaQueryWrapper<UserNotice>().in(UserNotice::getNoticeId, idList));
|
||||
}
|
||||
return isRemoved;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布通知公告
|
||||
*
|
||||
* @param id 通知公告ID
|
||||
* @return 是否发布成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean releaseNotice(Long id) {
|
||||
@Transactional
|
||||
public boolean publishNotice(Long id) {
|
||||
Notice notice = this.getById(id);
|
||||
Assert.notNull(notice, "通知公告不存在");
|
||||
Assert.isTrue(notice.getReleaseStatus() != 1, "通知公告已发布");
|
||||
notice.setReleaseStatus(1);
|
||||
notice.setReleaseBy(SecurityUtils.getUserId());
|
||||
notice.setReleaseTime(LocalDateTime.now());
|
||||
this.updateById(notice);
|
||||
//发布通知公告的同时,需要将通知公告发送给目标用户
|
||||
//先删除掉该通知公告之前对应的用户信息
|
||||
noticeStatusService.remove(new LambdaQueryWrapper<NoticeStatus>().eq(NoticeStatus::getNoticeId, id));
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (notice.getTarType() == 1) {
|
||||
Assert.notBlank(notice.getTarIds(), "指定用户不能为空");
|
||||
queryWrapper.in(User::getId, Arrays.asList(notice.getTarIds().split(SymbolConstant.COMMA)));
|
||||
if (notice == null) {
|
||||
throw new BusinessException("通知公告不存在");
|
||||
}
|
||||
//查询出目标用户,增加用户通知状态
|
||||
List<User> list = userService.list(queryWrapper);
|
||||
List<NoticeStatus> needSaveList = list.stream().map(user -> {
|
||||
NoticeStatus noticeStatus = new NoticeStatus();
|
||||
noticeStatus.setNoticeId(id);
|
||||
noticeStatus.setUserId(user.getId());
|
||||
noticeStatus.setReadStatus(0);
|
||||
return noticeStatus;
|
||||
}).toList();
|
||||
if(needSaveList.size() > 0){
|
||||
noticeStatusService.saveBatch(needSaveList);
|
||||
}
|
||||
//最后,给当前在线的用户发送websocket消息
|
||||
List<String> usernameList = null;
|
||||
if(notice.getTarType() == 1){
|
||||
List<Long> collect = needSaveList.stream().map(NoticeStatus::getUserId).collect(Collectors.toList());
|
||||
List<User> userList = userService.list(new LambdaQueryWrapper<User>().in(User::getId, collect).select(User::getUsername));
|
||||
usernameList = userList.stream().map(User::getUsername).collect(Collectors.toList());
|
||||
}
|
||||
MessageDTO message = new MessageDTO();
|
||||
message.setNoticeWay(NoticeWayEnum.WEBSOCKET);
|
||||
message.setReceiver(usernameList);
|
||||
message.setContent(getNoticeContent(notice));
|
||||
message.setSender(SecurityUtils.getUsername());
|
||||
messageHandler.sendMessage(message);
|
||||
return this.updateById(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义组合公告内容
|
||||
*
|
||||
* @param notice 通知公告
|
||||
* @return 自定义组合通知公告内容
|
||||
*/
|
||||
private String getNoticeContent(Notice notice) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("id", notice.getId());
|
||||
jsonObject.set("title", notice.getTitle());
|
||||
jsonObject.set("messageType", notice.getNoticeType());
|
||||
jsonObject.set("releaseTime", notice.getReleaseTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
jsonObject.set("type", "release");
|
||||
return jsonObject.toString();
|
||||
if (NoticePublishStatusEnum.PUBLISHED.getValue().equals(notice.getPublishStatus())) {
|
||||
throw new BusinessException("通知公告已发布");
|
||||
}
|
||||
|
||||
Integer targetType = notice.getTargetType();
|
||||
String targetUserIds = notice.getTargetUserIds();
|
||||
if (NoticeTargetTypeEnum.SPECIFIED.getValue().equals(targetType)
|
||||
&& StrUtil.isBlank(targetUserIds)) {
|
||||
throw new BusinessException("推送指定用户不能为空");
|
||||
}
|
||||
|
||||
notice.setPublishStatus(NoticePublishStatusEnum.PUBLISHED.getValue());
|
||||
notice.setPublisherId(SecurityUtils.getUserId());
|
||||
notice.setPublishTime(LocalDateTime.now());
|
||||
boolean publishResult = this.updateById(notice);
|
||||
|
||||
if (publishResult) {
|
||||
// 发布通知公告的同时,删除该通告之前的用户通知数据,因为可能是重新发布
|
||||
userNoticeService.remove(
|
||||
new LambdaQueryWrapper<UserNotice>().eq(UserNotice::getNoticeId, id)
|
||||
);
|
||||
|
||||
// 添加新的用户通知数据
|
||||
List<String> targetUserIdList = Arrays.asList(targetUserIds.split(","));
|
||||
List<User> targetUserList = userService.list(
|
||||
new LambdaQueryWrapper<User>()
|
||||
// 如果是指定用户,则筛选出指定用户
|
||||
.in(NoticeTargetTypeEnum.SPECIFIED.getValue().equals(targetType), User::getId, targetUserIdList)
|
||||
);
|
||||
|
||||
|
||||
List<UserNotice> userNoticeList = targetUserList.stream().map(user -> {
|
||||
UserNotice userNotice = new UserNotice();
|
||||
userNotice.setNoticeId(id);
|
||||
userNotice.setUserId(user.getId());
|
||||
userNotice.setIsRead(0);
|
||||
return userNotice;
|
||||
}).toList();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userNoticeList)) {
|
||||
userNoticeService.saveBatch(userNoticeList);
|
||||
}
|
||||
|
||||
Set<String> receivers = targetUserList.stream().map(User::getUsername).collect(Collectors.toSet());
|
||||
|
||||
Set<String> allOnlineUsers = onlineUserService.getAllOnlineUsers();
|
||||
|
||||
// 找出在线用户的通知接收者
|
||||
Set<String> onlineReceivers = new HashSet<>(CollectionUtil.intersection(receivers, allOnlineUsers));
|
||||
|
||||
|
||||
NoticeDTO noticeDTO = new NoticeDTO();
|
||||
noticeDTO.setId(id);
|
||||
noticeDTO.setTitle(notice.getTitle());
|
||||
noticeDTO.setType(notice.getType());
|
||||
|
||||
onlineReceivers.forEach(receiver -> messagingTemplate.convertAndSendToUser(receiver, "/queue/message", noticeDTO));
|
||||
}
|
||||
return publishResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,67 +232,65 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
* @return 是否撤回成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean recallNotice(Long id) {
|
||||
@Transactional
|
||||
public boolean revokeNotice(Long id) {
|
||||
Notice notice = this.getById(id);
|
||||
Assert.notNull(notice, "通知公告不存在");
|
||||
Assert.isTrue(notice.getReleaseStatus() == 1, "通知公告未发布");
|
||||
notice.setReleaseStatus(2);
|
||||
notice.setRecallTime(LocalDateTime.now());
|
||||
if (!this.updateById(notice)) {
|
||||
return false;
|
||||
if (notice == null) {
|
||||
throw new BusinessException("通知公告不存在");
|
||||
}
|
||||
//先删除掉该通知公告之前对应的用户信息
|
||||
noticeStatusService.remove(new LambdaQueryWrapper<NoticeStatus>().eq(NoticeStatus::getNoticeId, id));
|
||||
return true;
|
||||
|
||||
if (!NoticePublishStatusEnum.PUBLISHED.getValue().equals(notice.getPublishStatus())) {
|
||||
throw new BusinessException("通知公告未发布或已撤回");
|
||||
}
|
||||
|
||||
notice.setPublishStatus(NoticePublishStatusEnum.REVOKED.getValue());
|
||||
notice.setRevokeTime(LocalDateTime.now());
|
||||
notice.setUpdateBy(SecurityUtils.getUserId());
|
||||
|
||||
boolean revokeResult = this.updateById(notice);
|
||||
|
||||
if (revokeResult) {
|
||||
// 撤回通知公告的同时,需要删除通知公告对应的用户通知状态
|
||||
userNoticeService.remove(new LambdaQueryWrapper<UserNotice>()
|
||||
.eq(UserNotice::getNoticeId, id)
|
||||
);
|
||||
}
|
||||
return revokeResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 阅读通知公告
|
||||
* @param id 通知公告ID
|
||||
* @return 通知公告表单对象
|
||||
*/
|
||||
@Override
|
||||
public NoticeDetailVO readNotice(Long id) {
|
||||
NoticeDetailVO noticeDetailVO = this.getReadNoticeDetail(id);
|
||||
Assert.isTrue(noticeDetailVO != null && noticeDetailVO.getReleaseStatus() == 1, "公告不存在或未发布");
|
||||
//获取当前登录用户
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
LambdaQueryWrapper<NoticeStatus> queryWrapper = new LambdaQueryWrapper<NoticeStatus>()
|
||||
.eq(NoticeStatus::getUserId, userId)
|
||||
.eq(NoticeStatus::getNoticeId, id)
|
||||
.eq(NoticeStatus::getReadStatus, 0);
|
||||
NoticeStatus noticeStatus = noticeStatusService.getOne(queryWrapper);
|
||||
if (noticeStatus != null) {
|
||||
noticeStatus.setReadStatus(1);
|
||||
noticeStatusService.updateById(noticeStatus);
|
||||
}
|
||||
return noticeDetailVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阅读时通知公告详情
|
||||
* 阅读获取通知公告详情
|
||||
*
|
||||
* @param id 通知公告ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public NoticeDetailVO getReadNoticeDetail(Long id) {
|
||||
Assert.notNull(id, "公告ID不能为空");
|
||||
NoticeDetailVO noticeDetailVO = this.baseMapper.getReadNoticeVO(id);
|
||||
Assert.isTrue(noticeDetailVO != null, "公告不存在");
|
||||
return noticeDetailVO;
|
||||
public NoticeDetailVO getNoticeDetail(Long id) {
|
||||
NoticeBO noticeBO = this.baseMapper.getNoticeDetail(id);
|
||||
// 更新用户通知公告的阅读状态
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
userNoticeService.update(new LambdaUpdateWrapper<UserNotice>()
|
||||
.eq(UserNotice::getNoticeId, id)
|
||||
.eq(UserNotice::getUserId, userId)
|
||||
.eq(UserNotice::getIsRead, 0)
|
||||
.set(UserNotice::getIsRead, 1)
|
||||
);
|
||||
return noticeConverter.toDetailVO(noticeBO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的通知公告列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
@Override
|
||||
public IPage<NoticeStatusVO> getMyNoticePage(NoticeQuery queryParams) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
queryParams.setUserId(userId);
|
||||
return noticeStatusService.getMyNoticePage(new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),queryParams);
|
||||
public IPage<UserNoticePageVO> getMyNoticePage(NoticePageQuery queryParams) {
|
||||
queryParams.setUserId(SecurityUtils.getUserId());
|
||||
return userNoticeService.getMyNoticePage(
|
||||
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||
queryParams
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.youlai.boot.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.core.security.util.SecurityUtils;
|
||||
import com.youlai.boot.system.mapper.NoticeStatusMapper;
|
||||
import com.youlai.boot.system.model.entity.NoticeStatus;
|
||||
import com.youlai.boot.system.model.query.NoticeQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.model.vo.NoticeVO;
|
||||
import com.youlai.boot.system.service.NoticeStatusService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户公告状态服务实现类
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NoticeStatusServiceImpl extends ServiceImpl<NoticeStatusMapper, NoticeStatus> implements NoticeStatusService {
|
||||
|
||||
private final NoticeStatusMapper noticeStatusMapper;
|
||||
|
||||
/**
|
||||
* 获取未读的通知公告
|
||||
* @return 公告列表
|
||||
*/
|
||||
@Override
|
||||
public List<NoticeStatusVO> listUnreadNotices() {
|
||||
//获取当前登录用户
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return noticeStatusMapper.listUnreadNotices(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部标记为已读
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean readAll() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
LambdaUpdateWrapper<NoticeStatus> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(NoticeStatus::getUserId, userId);
|
||||
updateWrapper.set(NoticeStatus::getReadStatus, 1);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取我的通知公告
|
||||
* @param page 分页对象
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
@Override
|
||||
public IPage<NoticeStatusVO> getMyNoticePage(Page<NoticeVO> page, NoticeQuery queryParams) {
|
||||
return this.getBaseMapper().getMyNoticePage(new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),queryParams);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.youlai.boot.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.core.security.util.SecurityUtils;
|
||||
import com.youlai.boot.system.mapper.UserNoticeMapper;
|
||||
import com.youlai.boot.system.model.entity.UserNotice;
|
||||
import com.youlai.boot.system.model.query.NoticePageQuery;
|
||||
import com.youlai.boot.system.model.vo.NoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserNoticePageVO;
|
||||
import com.youlai.boot.system.model.vo.UserUnreadNoticeVO;
|
||||
import com.youlai.boot.system.service.UserNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户公告状态服务实现类
|
||||
*
|
||||
* @author youlaitech
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserNoticeServiceImpl extends ServiceImpl<UserNoticeMapper, UserNotice> implements UserNoticeService {
|
||||
|
||||
private final UserNoticeMapper userNoticeMapper;
|
||||
|
||||
/**
|
||||
* 获取未读的通知公告
|
||||
*
|
||||
* @return 公告列表
|
||||
*/
|
||||
@Override
|
||||
public List<UserUnreadNoticeVO> listUnreadNotices() {
|
||||
//获取当前登录用户
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return userNoticeMapper.listUnreadNotices(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部标记为已读
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean readAll() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return this.update(new LambdaUpdateWrapper<UserNotice>()
|
||||
.eq(UserNotice::getUserId, userId)
|
||||
.eq(UserNotice::getIsRead, 0)
|
||||
.set(UserNotice::getIsRead, 1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的通知公告分页列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryParams 查询参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
@Override
|
||||
public IPage<UserNoticePageVO> getMyNoticePage(Page<NoticePageVO> page, NoticePageQuery queryParams) {
|
||||
return this.getBaseMapper().getMyNoticePage(
|
||||
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
|
||||
queryParams
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.common.constant.RedisConstants;
|
||||
import com.youlai.boot.common.constant.SystemConstants;
|
||||
import com.youlai.boot.common.enums.ContactType;
|
||||
import com.youlai.boot.system.enums.ContactType;
|
||||
import com.youlai.boot.common.model.Option;
|
||||
import com.youlai.boot.module.mail.service.MailService;
|
||||
import com.youlai.boot.module.sms.service.SmsService;
|
||||
|
||||
Reference in New Issue
Block a user