From 036e4a7fc40a41779e688e0484c1ff83136941d1 Mon Sep 17 00:00:00 2001
From: 20987 <2098777519@qq.com>
Date: Thu, 16 Apr 2026 18:24:00 +0800
Subject: [PATCH] =?UTF-8?q?feat(announcement):=20=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E5=85=AC=E5=91=8A=E6=A0=8F=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 创建 Announcement 实体类,包含 ID、标题、内容、发布人等属性
- 实现公告状态和类型枚举描述功能
- 在 bean-di.xml 中配置三个公告实例的依赖注入
- 添加 setter 和构造器两种注入方式的测试用例
- 在 TestDi 测试类中集成公告模块的功能验证
- 提供公告状态描述和类型描述的获取方法
---
.idea/uiDesigner.xml | 124 ++++++++++++++++++
.../src/bean-di-annotation.xml | 14 +-
.../com/ssm/di/annotation/Announcement.java | 47 +++++++
.../com/ssm/di/annotation/TestAnnotation.java | 13 ++
.../grademanagement-SpringProject/bean-di.xml | 2 +-
5 files changed, 198 insertions(+), 2 deletions(-)
create mode 100644 .idea/uiDesigner.xml
create mode 100644 grademanagement-SpringProject/src/com/ssm/di/annotation/Announcement.java
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/grademanagement-SpringProject/src/bean-di-annotation.xml b/grademanagement-SpringProject/src/bean-di-annotation.xml
index 9d4582d..06075c4 100644
--- a/grademanagement-SpringProject/src/bean-di-annotation.xml
+++ b/grademanagement-SpringProject/src/bean-di-annotation.xml
@@ -10,7 +10,19 @@
-
+
+
+
+
+
+
diff --git a/grademanagement-SpringProject/src/com/ssm/di/annotation/Announcement.java b/grademanagement-SpringProject/src/com/ssm/di/annotation/Announcement.java
new file mode 100644
index 0000000..315129e
--- /dev/null
+++ b/grademanagement-SpringProject/src/com/ssm/di/annotation/Announcement.java
@@ -0,0 +1,47 @@
+package com.ssm.di.annotation;
+
+import org.springframework.stereotype.Component;
+
+@Component("announcement")
+public class Announcement {
+ private String title;
+ private String content;
+ private String publisher;
+ private String publishTime; // 新增:发布时间
+
+ // 无参构造(Spring 默认需要)
+ public Announcement() {}
+
+ // getter 和 setter
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(String publisher) {
+ this.publisher = publisher;
+ }
+
+ public String getPublishTime() {
+ return publishTime;
+ }
+
+ public void setPublishTime(String publishTime) {
+ this.publishTime = publishTime;
+ }
+}
\ No newline at end of file
diff --git a/grademanagement-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java b/grademanagement-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java
index bad9683..acb7e38 100644
--- a/grademanagement-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java
+++ b/grademanagement-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java
@@ -24,6 +24,19 @@ public class TestAnnotation {
// 4. 测试 toString() 方法输出
System.out.println("=== 调用 toString() 方法输出 ===");
System.out.println(department);
+ // 加载 Spring 配置文件(确保 xml 中有 )
+ ApplicationContext ac = new ClassPathXmlApplicationContext("xml/bean-di-annotation.xml");
+
+ // 获取公告栏 Bean
+ Announcement announcement = (Announcement) ac.getBean("announcement");
+
+ // 输出信息(可先手动赋值测试)
+ announcement.setTitle("系统维护通知");
+ announcement.setContent("系统将于今晚22:00进行维护,请提前保存数据。");
+ announcement.setPublisher("管理员");
+ announcement.setPublishTime("2025-04-05 10:00:00");
+
+ System.out.println(announcement.toString());
}
diff --git a/out/production/grademanagement-SpringProject/bean-di.xml b/out/production/grademanagement-SpringProject/bean-di.xml
index e0179f5..68dc884 100644
--- a/out/production/grademanagement-SpringProject/bean-di.xml
+++ b/out/production/grademanagement-SpringProject/bean-di.xml
@@ -5,7 +5,7 @@
http://www.springframework.org/schema/beans/spring-beans.xsd">
-
+