fix: 通知公告和字典重构问题修复
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.youlai.boot.core.filter;
|
||||
|
||||
import com.youlai.boot.common.util.IPUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -24,7 +25,8 @@ public class RequestLogFilter extends CommonsRequestLoggingFilter {
|
||||
@Override
|
||||
protected void beforeRequest(HttpServletRequest request, String message) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.info("request uri: {}", requestURI);
|
||||
String ip = IPUtils.getIpAddr(request);
|
||||
log.info("request,ip:{}, uri: {}", ip, requestURI);
|
||||
super.beforeRequest(request, message);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.youlai.boot.module.websocket.handler;
|
||||
|
||||
|
||||
import com.youlai.boot.module.websocket.service.OnlineUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 在线用户定时任务
|
||||
*
|
||||
* @since 2024/10/7
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class OnlineUserJobHandler {
|
||||
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
// 每分钟统计一次在线用户数
|
||||
@Scheduled(cron = "0 * * * * ?")
|
||||
public void execute() {
|
||||
log.info("定时任务:统计在线用户数");
|
||||
// 推送在线用户人数
|
||||
messagingTemplate.convertAndSend("/topic/onlineUserCount", onlineUserService.getOnlineUserCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
@Operation(summary = "获取我的通知公告分页列表")
|
||||
@GetMapping("/my/page")
|
||||
@GetMapping("/my-page")
|
||||
public PageResult<UserNoticePageVO> getMyNoticePage(
|
||||
NoticePageQuery queryParams
|
||||
) {
|
||||
|
||||
@@ -48,11 +48,6 @@ public class NoticeBO {
|
||||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 通知等级标签
|
||||
*/
|
||||
private String levelLabel;
|
||||
|
||||
/**
|
||||
* 目标类型(1: 全体 2: 指定)
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.youlai.boot.system.model.dto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -23,5 +24,8 @@ public class NoticeDTO {
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知时间")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public class DictDataForm {
|
||||
@Schema(description = "字典ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典值")
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -41,9 +41,6 @@ public class NoticePageVO implements Serializable {
|
||||
@Schema(description = "通知等级")
|
||||
private String level;
|
||||
|
||||
@Schema(description = "通知等级")
|
||||
private String levelLabel;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@@ -22,18 +22,15 @@ public class UserNoticePageVO {
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "通知等级")
|
||||
private String level;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private String typeLabel;
|
||||
|
||||
@Schema(description = "发布人姓名")
|
||||
private String publisherName;
|
||||
|
||||
@Schema(description = "通知级别")
|
||||
private String levelLabel;
|
||||
|
||||
@Schema(description = "发布时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
@@ -222,11 +222,11 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
// 找出在线用户的通知接收者
|
||||
Set<String> onlineReceivers = new HashSet<>(CollectionUtil.intersection(receivers, allOnlineUsers));
|
||||
|
||||
|
||||
NoticeDTO noticeDTO = new NoticeDTO();
|
||||
noticeDTO.setId(id);
|
||||
noticeDTO.setTitle(notice.getTitle());
|
||||
noticeDTO.setType(notice.getType());
|
||||
noticeDTO.setPublishTime(notice.getPublishTime());
|
||||
|
||||
onlineReceivers.forEach(receiver -> messagingTemplate.convertAndSendToUser(receiver, "/queue/message", noticeDTO));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user