diff --git a/login-notice-popup.js b/login-notice-popup.js new file mode 100644 index 00000000..e69de29b diff --git a/notice-popup-utils.js b/notice-popup-utils.js new file mode 100644 index 00000000..e69de29b diff --git a/notice-popup.js b/notice-popup.js new file mode 100644 index 00000000..e69de29b diff --git a/notice-popup.vue b/notice-popup.vue new file mode 100644 index 00000000..e69de29b diff --git a/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysNoticeController.java b/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysNoticeController.java index 1d5751a9..9fe8c707 100644 --- a/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysNoticeController.java +++ b/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysNoticeController.java @@ -61,22 +61,44 @@ public class SysNoticeController extends BaseController { /** * 获取当前用户的通知列表(公开接口) - * 通知类型:通常 noticeType = '1' 代表通知 + * 通知类型:通常 noticeType = '1' 代表通知,noticeType = '2' 代表公告 + * 返回已发布且状态正常的所有公告和通知,并标注已读状态 + * 按优先级排序,高优先级在前 */ @GetMapping("/public/notice") public AjaxResult getUserNotices() { // 获取当前用户信息 LoginUser loginUser = getLoginUser(); SysUser currentUser = loginUser.getUser(); - - // 只查询状态为正常(0)且已发布(1)的通知 + + // 查询已发布且状态正常的所有公告和通知 SysNotice notice = new SysNotice(); notice.setStatus("0"); notice.setPublishStatus("1"); - // 通知类型设置为 '1'(通知) - notice.setNoticeType("1"); - + List list = noticeService.selectNoticeList(notice); + + // 按优先级排序(1高 2中 3低),相同优先级按创建时间降序 + list.sort((a, b) -> { + String priorityA = a.getPriority() != null ? a.getPriority() : "3"; + String priorityB = b.getPriority() != null ? b.getPriority() : "3"; + int priorityCompare = priorityA.compareTo(priorityB); + if (priorityCompare != 0) { + return priorityCompare; + } + // 相同优先级,按创建时间降序 + return b.getCreateTime().compareTo(a.getCreateTime()); + }); + + // 获取用户已读的公告/通知ID列表 + List readIds = noticeReadService.selectReadNoticeIdsByUserId(currentUser.getUserId()); + + // 为每个公告/通知添加已读状态 + for (SysNotice item : list) { + boolean isRead = readIds.contains(item.getNoticeId()); + item.setIsRead(isRead); + } + return success(list); } @@ -143,6 +165,10 @@ public class SysNoticeController extends BaseController { if (notice.getPublishStatus() == null || notice.getPublishStatus().isEmpty()) { notice.setPublishStatus("0"); } + // 设置默认优先级为中(2) + if (notice.getPriority() == null || notice.getPriority().isEmpty()) { + notice.setPriority("2"); + } return toAjax(noticeService.insertNotice(notice)); } diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNotice.java b/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNotice.java index a1981022..1ad62207 100644 --- a/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNotice.java +++ b/openhis-server-new/core-system/src/main/java/com/core/system/domain/SysNotice.java @@ -34,6 +34,12 @@ public class SysNotice extends BaseEntity { /** 发布状态(0未发布 1已发布) */ private String publishStatus; + /** 优先级(1高 2中 3低) */ + private String priority; + + /** 是否已读(前端展示用,不映射到数据库) */ + private Boolean isRead; + public Long getNoticeId() { return noticeId; } @@ -85,6 +91,22 @@ public class SysNotice extends BaseEntity { this.publishStatus = publishStatus; } + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public Boolean getIsRead() { + return isRead; + } + + public void setIsRead(Boolean isRead) { + this.isRead = isRead; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("noticeId", getNoticeId()) diff --git a/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeMapper.xml index 59c39912..a4da59b2 100644 --- a/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/openhis-server-new/core-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -11,6 +11,7 @@ + @@ -25,6 +26,7 @@ convert_from(notice_content, 'UTF8') as notice_content, status, publish_status, + priority, create_by, create_time, update_by, @@ -67,6 +69,7 @@ notice_type, notice_content, status, + priority, remark, create_by, create_time @@ -76,6 +79,7 @@ #{noticeType}, cast(#{noticeContent} as bytea), #{status}, + #{priority}, #{remark}, #{createBy}, now() @@ -90,6 +94,7 @@ notice_content = cast(#{noticeContent} as bytea), status = #{status}, publish_status = #{publishStatus}, + priority = #{priority}, update_by = #{updateBy}, update_time = now() diff --git a/openhis-server-new/openhis-application/src/main/resources/application-dev.yml b/openhis-server-new/openhis-application/src/main/resources/application-dev.yml index fe94317c..500e9758 100644 --- a/openhis-server-new/openhis-application/src/main/resources/application-dev.yml +++ b/openhis-server-new/openhis-application/src/main/resources/application-dev.yml @@ -6,7 +6,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=hisdev&characterEncoding=UTF-8&client_encoding=UTF-8 + url: jdbc:postgresql://47.116.196.11:15432/postgresql?currentSchema=hisdev&characterEncoding=UTF-8&client_encoding=UTF-8 username: postgresql password: Jchl1528 # 从库数据源 @@ -64,9 +64,9 @@ spring: # redis 配置 redis: # 地址 - host: 192.168.110.252 + host: 47.116.196.11 # 端口,默认为6379 - port: 6379 + port: 26379 # 数据库索引 database: 1 # 密码 diff --git a/openhis-server-new/sql/add_priority_to_sys_notice.sql b/openhis-server-new/sql/add_priority_to_sys_notice.sql new file mode 100644 index 00000000..b7521913 --- /dev/null +++ b/openhis-server-new/sql/add_priority_to_sys_notice.sql @@ -0,0 +1,10 @@ +-- 为 sys_notice 表添加优先级字段 +-- 执行前请先备份数据库 + +ALTER TABLE sys_notice ADD COLUMN priority VARCHAR(10) DEFAULT '2'; + +-- 添加注释 +COMMENT ON COLUMN sys_notice.priority IS '优先级(1高 2中 3低)'; + +-- 为现有数据设置默认优先级 +UPDATE sys_notice SET priority = '2' WHERE priority IS NULL; diff --git a/openhis-ui-vue3/src/components/NoticePanel/index.vue b/openhis-ui-vue3/src/components/NoticePanel/index.vue new file mode 100644 index 00000000..bcfa6992 --- /dev/null +++ b/openhis-ui-vue3/src/components/NoticePanel/index.vue @@ -0,0 +1,557 @@ + + + + + diff --git a/openhis-ui-vue3/src/components/NoticePopup/index.vue b/openhis-ui-vue3/src/components/NoticePopup/index.vue new file mode 100644 index 00000000..effd4cbc --- /dev/null +++ b/openhis-ui-vue3/src/components/NoticePopup/index.vue @@ -0,0 +1,592 @@ + + + + + diff --git a/openhis-ui-vue3/src/layout/index.vue b/openhis-ui-vue3/src/layout/index.vue index 5dbd5d5c..235521ad 100644 --- a/openhis-ui-vue3/src/layout/index.vue +++ b/openhis-ui-vue3/src/layout/index.vue @@ -16,6 +16,8 @@ + + @@ -23,6 +25,7 @@ import {useWindowSize} from '@vueuse/core'; import Sidebar from './components/Sidebar/index.vue'; import {AppMain, Settings, TagsView} from './components'; +import NoticePopup from '@/components/NoticePopup/index.vue'; import useAppStore from '@/store/modules/app'; import useSettingsStore from '@/store/modules/settings'; @@ -62,9 +65,16 @@ function handleClickOutside() { } const settingRef = ref(null); +const noticePopupRef = ref(null); + function setLayout() { settingRef.value.openSetting(); } + +// 暴露公告弹窗引用,供其他组件调用 +defineExpose({ + noticePopupRef +});