diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNoticeRead.java b/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNoticeRead.java new file mode 100644 index 00000000..01b265dc --- /dev/null +++ b/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNoticeRead.java @@ -0,0 +1,61 @@ +package com.core.system.domain; + +import com.core.common.core.domain.BaseEntity; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + +/** + * 公告/通知已读记录 sys_notice_read + * + * @author system + */ +public class SysNoticeRead extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 阅读ID */ + @JsonSerialize(using = ToStringSerializer.class) + private Long readId; + + /** 公告/通知ID */ + @JsonSerialize(using = ToStringSerializer.class) + private Long noticeId; + + /** 用户ID */ + @JsonSerialize(using = ToStringSerializer.class) + private Long userId; + + /** 阅读时间 */ + private String readTime; + + public Long getReadId() { + return readId; + } + + public void setReadId(Long readId) { + this.readId = readId; + } + + public Long getNoticeId() { + return noticeId; + } + + public void setNoticeId(Long noticeId) { + this.noticeId = noticeId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getReadTime() { + return readTime; + } + + public void setReadTime(String readTime) { + this.readTime = readTime; + } +} diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/mapper/SysNoticeReadMapper.java b/openhis-server-new/core-system/src/main/java/com/core/system/mapper/SysNoticeReadMapper.java new file mode 100644 index 00000000..66c960dc --- /dev/null +++ b/openhis-server-new/core-system/src/main/java/com/core/system/mapper/SysNoticeReadMapper.java @@ -0,0 +1,70 @@ +package com.core.system.mapper; + +import java.util.List; + +import com.core.system.domain.SysNoticeRead; + +/** + * 公告/通知已读记录 Mapper接口 + * + * @author system + */ +public interface SysNoticeReadMapper { + + /** + * 查询公告/通知已读记录 + * + * @param readId 阅读ID + * @return 公告/通知已读记录 + */ + public SysNoticeRead selectNoticeReadById(Long readId); + + /** + * 查询用户的已读公告/通知ID列表 + * + * @param userId 用户ID + * @return 已读公告/通知ID列表 + */ + public List selectReadNoticeIdsByUserId(Long userId); + + /** + * 查询公告/通知的已读用户数量 + * + * @param noticeId 公告/通知ID + * @return 已读用户数量 + */ + public int countReadByNoticeId(Long noticeId); + + /** + * 新增公告/通知已读记录 + * + * @param noticeRead 公告/通知已读记录 + * @return 结果 + */ + public int insertNoticeRead(SysNoticeRead noticeRead); + + /** + * 删除公告/通知已读记录 + * + * @param readId 阅读ID + * @return 结果 + */ + public int deleteNoticeReadById(Long readId); + + /** + * 批量删除公告/通知已读记录 + * + * @param readIds 需要删除的阅读ID + * @return 结果 + */ + public int deleteNoticeReadByIds(Long[] readIds); + + /** + * 检查用户是否已阅读公告/通知 + * + * @param noticeId 公告/通知ID + * @param userId 用户ID + * @return 是否已阅读 + */ + public boolean checkNoticeRead(Long noticeId, Long userId); +} diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/service/ISysNoticeReadService.java b/openhis-server-new/core-system/src/main/java/com/core/system/service/ISysNoticeReadService.java new file mode 100644 index 00000000..8abd2240 --- /dev/null +++ b/openhis-server-new/core-system/src/main/java/com/core/system/service/ISysNoticeReadService.java @@ -0,0 +1,58 @@ +package com.core.system.service; + +import java.util.List; + +import com.core.common.core.domain.AjaxResult; +import com.core.system.domain.SysNotice; +import com.core.system.domain.SysNoticeRead; + +/** + * 公告/通知已读记录 服务层 + * + * @author system + */ +public interface ISysNoticeReadService { + + /** + * 查询用户的未读公告/通知数量 + * + * @param userId 用户ID + * @return 未读数量 + */ + public int getUnreadCount(Long userId); + + /** + * 标记公告/通知为已读 + * + * @param noticeId 公告/通知ID + * @param userId 用户ID + * @return 结果 + */ + public AjaxResult markAsRead(Long noticeId, Long userId); + + /** + * 批量标记公告/通知为已读 + * + * @param noticeIds 公告/通知ID列表 + * @param userId 用户ID + * @return 结果 + */ + public AjaxResult markAllAsRead(Long[] noticeIds, Long userId); + + /** + * 查询用户的已读公告/通知ID列表 + * + * @param userId 用户ID + * @return 已读公告/通知ID列表 + */ + public List selectReadNoticeIdsByUserId(Long userId); + + /** + * 查询带已读状态的公告列表 + * + * @param notice 公告信息 + * @param userId 用户ID + * @return 公告集合 + */ + public List selectNoticeListWithReadStatus(SysNotice notice, Long userId); +} diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysNoticeReadServiceImpl.java b/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysNoticeReadServiceImpl.java new file mode 100644 index 00000000..4ea7f249 --- /dev/null +++ b/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysNoticeReadServiceImpl.java @@ -0,0 +1,130 @@ +package com.core.system.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.core.common.core.domain.AjaxResult; +import com.core.system.domain.SysNotice; +import com.core.system.domain.SysNoticeRead; +import com.core.system.mapper.SysNoticeMapper; +import com.core.system.mapper.SysNoticeReadMapper; +import com.core.system.service.ISysNoticeReadService; + +/** + * 公告/通知已读记录 服务层实现 + * + * @author system + */ +@Service +public class SysNoticeReadServiceImpl implements ISysNoticeReadService { + + @Autowired + private SysNoticeReadMapper noticeReadMapper; + + @Autowired + private SysNoticeMapper noticeMapper; + + /** + * 查询用户的未读公告/通知数量 + * + * @param userId 用户ID + * @return 未读数量 + */ + @Override + public int getUnreadCount(Long userId) { + // 查询所有状态为正常(0)的公告/通知 + SysNotice notice = new SysNotice(); + notice.setStatus("0"); + List allNotices = noticeMapper.selectNoticeList(notice); + + // 查询用户已读的公告/通知ID + List readNoticeIds = noticeReadMapper.selectReadNoticeIdsByUserId(userId); + + // 计算未读数量 + int unreadCount = 0; + for (SysNotice n : allNotices) { + if (!readNoticeIds.contains(n.getNoticeId())) { + unreadCount++; + } + } + + return unreadCount; + } + + /** + * 标记公告/通知为已读 + * + * @param noticeId 公告/通知ID + * @param userId 用户ID + * @return 结果 + */ + @Override + public AjaxResult markAsRead(Long noticeId, Long userId) { + // 检查是否已读 + boolean isRead = noticeReadMapper.checkNoticeRead(noticeId, userId); + if (isRead) { + return AjaxResult.success("已标记为已读"); + } + + // 插入已读记录 + SysNoticeRead noticeRead = new SysNoticeRead(); + noticeRead.setNoticeId(noticeId); + noticeRead.setUserId(userId); + + int result = noticeReadMapper.insertNoticeRead(noticeRead); + if (result > 0) { + return AjaxResult.success("标记成功"); + } + return AjaxResult.error("标记失败"); + } + + /** + * 批量标记公告/通知为已读 + * + * @param noticeIds 公告/通知ID列表 + * @param userId 用户ID + * @return 结果 + */ + @Override + public AjaxResult markAllAsRead(Long[] noticeIds, Long userId) { + int successCount = 0; + for (Long noticeId : noticeIds) { + boolean isRead = noticeReadMapper.checkNoticeRead(noticeId, userId); + if (!isRead) { + SysNoticeRead noticeRead = new SysNoticeRead(); + noticeRead.setNoticeId(noticeId); + noticeRead.setUserId(userId); + noticeReadMapper.insertNoticeRead(noticeRead); + successCount++; + } + } + return AjaxResult.success("成功标记" + successCount + "条记录为已读"); + } + + /** + * 查询用户的已读公告/通知ID列表 + * + * @param userId 用户ID + * @return 已读公告/通知ID列表 + */ + @Override + public List selectReadNoticeIdsByUserId(Long userId) { + return noticeReadMapper.selectReadNoticeIdsByUserId(userId); + } + + /** + * 查询带已读状态的公告列表 + * + * @param notice 公告信息 + * @param userId 用户ID + * @return 公告集合 + */ + @Override + public List selectNoticeListWithReadStatus(SysNotice notice, Long userId) { + // 这里可以扩展为在查询结果中添加已读状态标记 + // 暂时返回普通列表 + return noticeMapper.selectNoticeList(notice); + } +} diff --git a/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeReadMapper.xml b/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeReadMapper.xml new file mode 100644 index 00000000..e7ea7683 --- /dev/null +++ b/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeReadMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + insert into sys_notice_read ( + read_id, + notice_id, + user_id, + read_time + ) values ( + (SELECT COALESCE(MAX(read_id), 0) + 1 FROM sys_notice_read), + #{noticeId}, + #{userId}, + now() + ) + + + + delete from sys_notice_read where read_id = #{readId} + + + + delete from sys_notice_read where read_id in + + #{readId} + + + + diff --git a/openhis-ui-vue3/src/components/NoticePanel.vue b/openhis-ui-vue3/src/components/NoticePanel.vue new file mode 100644 index 00000000..57dc1dcf --- /dev/null +++ b/openhis-ui-vue3/src/components/NoticePanel.vue @@ -0,0 +1,249 @@ + + + + + diff --git a/发版记录/2025-12-24/~$ Microsoft Word 文档.docx b/发版记录/2025-12-24/~$ Microsoft Word 文档.docx new file mode 100644 index 00000000..a29e778b Binary files /dev/null and b/发版记录/2025-12-24/~$ Microsoft Word 文档.docx differ diff --git a/迁移记录-DB变更记录/2025-12-30 add_column_sys_notice_publish_status.sql b/迁移记录-DB变更记录/2025-12-30 add_column_sys_notice_publish_status.sql new file mode 100644 index 00000000..09cc9678 --- /dev/null +++ b/迁移记录-DB变更记录/2025-12-30 add_column_sys_notice_publish_status.sql @@ -0,0 +1,8 @@ +-- 添加公告/通知发布状态字段 +ALTER TABLE sys_notice ADD COLUMN publish_status VARCHAR(1) DEFAULT '0'; + +-- 添加字段注释 +COMMENT ON COLUMN sys_notice.publish_status IS '发布状态(0未发布 1已发布)'; + +-- 更新现有数据为已发布状态 +UPDATE sys_notice SET publish_status = '1' WHERE publish_status IS NULL; diff --git a/迁移记录-DB变更记录/2025-12-30 add_table_sys_notice_read.sql b/迁移记录-DB变更记录/2025-12-30 add_table_sys_notice_read.sql new file mode 100644 index 00000000..88e13290 --- /dev/null +++ b/迁移记录-DB变更记录/2025-12-30 add_table_sys_notice_read.sql @@ -0,0 +1,26 @@ +-- 公告/通知已读记录表 +CREATE TABLE IF NOT EXISTS sys_notice_read ( + read_id BIGINT PRIMARY KEY, + notice_id BIGINT NOT NULL, + user_id BIGINT NOT NULL, + read_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT uk_notice_user UNIQUE (notice_id, user_id) +); + +COMMENT ON TABLE sys_notice_read IS '公告/通知已读记录表'; +COMMENT ON COLUMN sys_notice_read.read_id IS '阅读ID'; +COMMENT ON COLUMN sys_notice_read.notice_id IS '公告/通知ID'; +COMMENT ON COLUMN sys_notice_read.user_id IS '用户ID'; +COMMENT ON COLUMN sys_notice_read.read_time IS '阅读时间'; + +-- 创建序列 +CREATE SEQUENCE IF NOT EXISTS sys_notice_read_read_id_seq +INCREMENT 1 +MINVALUE 1 +MAXVALUE 99999999 +START 200 +CACHE 1; + +-- 索引 +CREATE INDEX IF NOT EXISTS idx_notice_read_notice_id ON sys_notice_read(notice_id); +CREATE INDEX IF NOT EXISTS idx_notice_read_user_id ON sys_notice_read(user_id);