消息模块、爬虫

This commit is contained in:
2025-11-13 19:00:27 +08:00
parent 2982d53800
commit e20a7755f8
85 changed files with 8637 additions and 201 deletions

View File

@@ -6,16 +6,22 @@
<parent>
<groupId>org.xyzh</groupId>
<artifactId>common</artifactId>
<version>${school-news.version}</version>
<version>1.0.0</version>
</parent>
<groupId>org.xyzh</groupId>
<artifactId>common-dto</artifactId>
<version>${school-news.version}</version>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,95 @@
package org.xyzh.common.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 创建消息请求DTO
*
* @description 用于接收前端创建消息的请求参数
* @filename MessageCreateDTO.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
public class MessageCreateDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 消息标题(必填)
*/
private String title;
/**
* 消息内容(必填)
*/
private String content;
/**
* 消息类型notification-通知/announcement-公告/warning-预警
* 默认notification
*/
private String messageType = "notification";
/**
* 优先级normal-普通/important-重要/urgent-紧急
* 默认normal
*/
private String priority = "normal";
/**
* 发送模式immediate-立即发送/scheduled-定时发送
* 默认immediate
*/
private String sendMode = "immediate";
/**
* 计划发送时间sendMode=scheduled时必填
*/
private Date scheduledTime;
/**
* 接收对象列表(必填)
*/
private List<MessageTargetDTO> targets;
/**
* 内部类接收对象DTO
*/
@Data
public static class MessageTargetDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 发送方式system/email/sms多选时逗号分隔
* 默认system
*/
private String sendMethod = "system";
/**
* 接收对象类型dept-部门/role-角色/user-人员
*/
private String targetType;
/**
* 接收对象ID
*/
private String targetID;
/**
* 接收对象名称(前端传递,用于冗余存储)
*/
private String targetName;
/**
* 作用域部门ID关键字段
* - dept时与targetID相同
* - role时限定该角色的部门范围
* - user时用户所属部门ID
*/
private String scopeDeptID;
}
}

View File

@@ -0,0 +1,120 @@
package org.xyzh.common.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户消息视图对象
*
* @description 用于前端展示的用户消息对象,包含用户信息和消息阅读状态
* @filename MessageUserVO.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
public class MessageUserVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private String id;
/**
* 消息ID
*/
private String messageID;
/**
* 用户ID
*/
private String userID;
/**
* 用户名
*/
private String username;
/**
* 用户姓名
*/
private String fullName;
/**
* 用户所属部门ID
*/
private String deptID;
/**
* 用户所属部门名称
*/
private String deptName;
/**
* 实际发送方式system-系统消息/email-邮件/sms-短信
*/
private String sendMethod;
/**
* 是否已读0-未读1-已读
*/
private Boolean isRead;
/**
* 阅读时间
*/
private Date readTime;
/**
* 发送状态pending-待发送/success-发送成功/failed-发送失败
*/
private String sendStatus;
/**
* 失败原因
*/
private String failReason;
/**
* 创建时间
*/
private Date createTime;
// ========== 消息主体信息(用户端查看消息列表时需要) ==========
/**
* 消息标题
*/
private String title;
/**
* 消息内容
*/
private String content;
/**
* 消息类型
*/
private String messageType;
/**
* 优先级
*/
private String priority;
/**
* 发送人姓名
*/
private String senderName;
/**
* 发送人部门名称
*/
private String senderDeptName;
/**
* 实际发送时间
*/
private Date actualSendTime;
}

View File

@@ -0,0 +1,192 @@
package org.xyzh.common.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 消息视图对象
*
* @description 用于前端展示的消息对象,包含消息主体信息和关联的接收对象列表
* @filename MessageVO.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
public class MessageVO implements Serializable {
private static final long serialVersionUID = 1L;
// ========== 消息主体信息 ==========
/**
* 主键ID
*/
private String id;
/**
* 消息唯一标识
*/
private String messageID;
/**
* 消息标题
*/
private String title;
/**
* 消息内容
*/
private String content;
/**
* 消息类型notification-通知/announcement-公告/warning-预警
*/
private String messageType;
/**
* 优先级normal-普通/important-重要/urgent-紧急
*/
private String priority;
/**
* 发送人用户ID
*/
private String senderID;
/**
* 发送人姓名
*/
private String senderName;
/**
* 发送人部门ID
*/
private String senderDeptID;
/**
* 发送人部门名称
*/
private String senderDeptName;
/**
* 发送模式immediate-立即发送/scheduled-定时发送
*/
private String sendMode;
/**
* 计划发送时间
*/
private Date scheduledTime;
/**
* 实际发送时间
*/
private Date actualSendTime;
/**
* 状态draft-草稿/pending-待发送/sending-发送中/sent-已发送/failed-失败/cancelled-已取消
*/
private String status;
/**
* 目标用户总数
*/
private Integer targetUserCount;
/**
* 已发送数量
*/
private Integer sentCount;
/**
* 发送成功数量
*/
private Integer successCount;
/**
* 发送失败数量
*/
private Integer failedCount;
/**
* 已读数量
*/
private Integer readCount;
/**
* 当前重试次数
*/
private Integer retryCount;
/**
* 最大重试次数
*/
private Integer maxRetryCount;
/**
* 最后错误信息
*/
private String lastError;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
// ========== 关联信息 ==========
/**
* 接收对象列表
*/
private List<TbSysMessageTarget> targets;
/**
* 用户接收记录列表(仅在详情查询时返回)
*/
private List<MessageUserVO> userMessages;
// ========== 计算属性 ==========
/**
* 发送进度百分比0-100
*/
public Integer getSendProgress() {
if (targetUserCount == null || targetUserCount == 0) {
return 0;
}
if (sentCount == null) {
return 0;
}
return (int) Math.round((sentCount * 100.0) / targetUserCount);
}
/**
* 成功率百分比0-100
*/
public Integer getSuccessRate() {
if (sentCount == null || sentCount == 0) {
return 0;
}
if (successCount == null) {
return 0;
}
return (int) Math.round((successCount * 100.0) / sentCount);
}
/**
* 已读率百分比0-100
*/
public Integer getReadRate() {
if (successCount == null || successCount == 0) {
return 0;
}
if (readCount == null) {
return 0;
}
return (int) Math.round((readCount * 100.0) / successCount);
}
}

View File

@@ -0,0 +1,148 @@
package org.xyzh.common.dto.message;
import org.xyzh.common.dto.BaseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 消息主体表实体类
*
* @description 消息通知模块的主体表,存储消息的基本信息、发送配置和统计数据
* @filename TbSysMessage.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class TbSysMessage extends BaseDTO {
private static final long serialVersionUID = 1L;
/**
* 消息唯一标识
*/
private String messageID;
/**
* 消息标题
*/
private String title;
/**
* 消息内容
*/
private String content;
/**
* 消息类型notification-通知/announcement-公告/warning-预警
*/
private String messageType;
/**
* 优先级normal-普通/important-重要/urgent-紧急
*/
private String priority;
/**
* 发送人用户ID
*/
private String senderID;
/**
* 发送人姓名(冗余字段)
*/
private String senderName;
/**
* 发送人部门ID
*/
private String senderDeptID;
/**
* 发送人部门名称(冗余字段)
*/
private String senderDeptName;
/**
* 发送模式immediate-立即发送/scheduled-定时发送
*/
private String sendMode;
/**
* 计划发送时间sendMode=scheduled时必填
*/
private Date scheduledTime;
/**
* 实际发送时间
*/
private Date actualSendTime;
/**
* 状态draft-草稿/pending-待发送/sending-发送中/sent-已发送/failed-失败/cancelled-已取消
*/
private String status;
/**
* 目标用户总数
*/
private Integer targetUserCount;
/**
* 已发送数量
*/
private Integer sentCount;
/**
* 发送成功数量
*/
private Integer successCount;
/**
* 发送失败数量
*/
private Integer failedCount;
/**
* 已读数量
*/
private Integer readCount;
/**
* 当前重试次数
*/
private Integer retryCount;
/**
* 最大重试次数
*/
private Integer maxRetryCount;
/**
* 最后错误信息
*/
private String lastError;
/**
* 创建人ID
*/
private String creator;
/**
* 更新人ID
*/
private String updater;
/**
* 发送目标配置列表(前端辅助字段,不映射到数据库)
*/
private List<TbSysMessageTarget> targets;
/**
* 发送方式列表前端辅助字段从targets聚合
*/
private List<String> sendMethods;
}

View File

@@ -0,0 +1,64 @@
package org.xyzh.common.dto.message;
import org.xyzh.common.dto.BaseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 消息发送方式接收对象表实体类
*
* @description 存储消息的接收对象配置,包括发送方式、目标类型和作用域部门
* @filename TbSysMessageTarget.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class TbSysMessageTarget extends BaseDTO {
private static final long serialVersionUID = 1L;
/**
* 消息ID关联tb_sys_message.messageID
*/
private String messageID;
/**
* 发送方式system-系统消息/email-邮件/sms-短信
* 多选时逗号分隔system,email
*/
private String sendMethod;
/**
* 接收对象类型dept-部门/role-角色/user-人员
*/
private String targetType;
/**
* 接收对象ID部门ID/角色ID/用户ID
*/
private String targetID;
/**
* 接收对象名称(冗余字段,便于展示)
*/
private String targetName;
/**
* 作用域部门ID
* - dept时与targetID相同
* - role时表示该角色限定在哪个部门及其子部门范围内
* - user时用户所属部门ID
*/
private String scopeDeptID;
/**
* 创建人ID
*/
private String creator;
/**
* 更新人ID
*/
private String updater;
}

View File

@@ -0,0 +1,68 @@
package org.xyzh.common.dto.message;
import org.xyzh.common.dto.BaseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 用户接收消息表实体类
*
* @description 存储每个用户接收到的消息记录,包括阅读状态和发送状态
* @filename TbSysMessageUser.java
* @author Claude
* @copyright xyzh
* @since 2025-11-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class TbSysMessageUser extends BaseDTO {
private static final long serialVersionUID = 1L;
/**
* 消息ID关联tb_sys_message.messageID
*/
private String messageID;
/**
* 接收用户ID
*/
private String userID;
/**
* 实际发送方式system-系统消息/email-邮件/sms-短信
*/
private String sendMethod;
/**
* 是否已读0-未读1-已读
*/
private Boolean isRead;
/**
* 阅读时间
*/
private Date readTime;
/**
* 发送状态pending-待发送/success-发送成功/failed-发送失败
*/
private String sendStatus;
/**
* 失败原因
*/
private String failReason;
/**
* 创建人ID
*/
private String creator;
/**
* 更新人ID
*/
private String updater;
}