diff --git a/grademanagement-SpringProject/src/bean-aop-xml.xml b/grademanagement-SpringProject/src/bean-aop-xml.xml
index 6434a33..dfee121 100644
--- a/grademanagement-SpringProject/src/bean-aop-xml.xml
+++ b/grademanagement-SpringProject/src/bean-aop-xml.xml
@@ -42,5 +42,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/grademanagement-SpringProject/src/com/ssm/aop/xml/Announcement.java b/grademanagement-SpringProject/src/com/ssm/aop/xml/Announcement.java
new file mode 100644
index 0000000..713133c
--- /dev/null
+++ b/grademanagement-SpringProject/src/com/ssm/aop/xml/Announcement.java
@@ -0,0 +1,171 @@
+package com.ssm.aop.xml;
+
+/**
+ * 公告栏实体类
+ * 对应模块:公告栏管理
+ */
+public class Announcement {
+ // 公告ID
+ private Integer id;
+ // 公告标题
+ private String title;
+ // 公告内容
+ private String content;
+ // 发布人
+ private String publisher;
+ // 发布时间(改为String类型,避免转换问题)
+ private String publishTime;
+ // 公告状态(0:草稿 1:已发布 2:已下架)
+ private Integer status;
+ // 公告类型(1:通知 2:重要 3:活动 4:系统 5:紧急)
+ private Integer type;
+ // 截止日期(改为String类型)
+ private String expireDate;
+ // 阅读次数
+ private Integer readCount;
+
+ // 无参构造
+ public Announcement() {}
+
+ // 有参构造
+ public Announcement(Integer id, String title, String content, String publisher,
+ String publishTime, Integer status, Integer type,
+ String expireDate, Integer readCount) {
+ this.id = id;
+ this.title = title;
+ this.content = content;
+ this.publisher = publisher;
+ this.publishTime = publishTime;
+ this.status = status;
+ this.type = type;
+ this.expireDate = expireDate;
+ this.readCount = readCount;
+ }
+
+ // Getter & Setter 方法
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ 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;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public Integer getType() {
+ return type;
+ }
+
+ public void setType(Integer type) {
+ this.type = type;
+ }
+
+ public String getExpireDate() {
+ return expireDate;
+ }
+
+ public void setExpireDate(String expireDate) {
+ this.expireDate = expireDate;
+ }
+
+ public Integer getReadCount() {
+ return readCount;
+ }
+
+ public void setReadCount(Integer readCount) {
+ this.readCount = readCount;
+ }
+
+ // 获取状态描述
+ public String getStatusDesc() {
+ switch (status) {
+ case 0: return "草稿";
+ case 1: return "已发布";
+ case 2: return "已下架";
+ default: return "未知";
+ }
+ }
+
+ // 获取类型描述
+ public String getTypeDesc() {
+ switch (type) {
+ case 1: return "通知";
+ case 2: return "重要";
+ case 3: return "活动";
+ case 4: return "系统";
+ case 5: return "紧急";
+ default: return "未知";
+ }
+ }
+
+ /**
+ * 自定义printInfo方法:控制台打印公告信息
+ */
+ public void printInfo() {
+ System.out.println("===== 【公告管理】信息 =====");
+ System.out.println("公告ID : " + id);
+ System.out.println("公告标题 : " + title);
+ System.out.println("公告内容 : " + content);
+ System.out.println("发布人 : " + publisher);
+ System.out.println("发布时间 : " + publishTime);
+ System.out.println("状态 : " + getStatusDesc());
+ System.out.println("类型 : " + getTypeDesc());
+ System.out.println("截止日期 : " + expireDate);
+ System.out.println("阅读次数 : " + readCount);
+ System.out.println("==========================\n");
+ }
+
+ @Override
+ public String toString() {
+ return "Announcement{" +
+ "id=" + id +
+ ", title='" + title + '\'' +
+ ", content='" + content + '\'' +
+ ", publisher='" + publisher + '\'' +
+ ", publishTime='" + publishTime + '\'' +
+ ", status=" + status + "(" + getStatusDesc() + ")" +
+ ", type=" + type + "(" + getTypeDesc() + ")" +
+ ", expireDate='" + expireDate + '\'' +
+ ", readCount=" + readCount +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/grademanagement-SpringProject/src/com/ssm/aop/xml/Log.java b/grademanagement-SpringProject/src/com/ssm/aop/xml/Log.java
index 4a56c14..7697f2f 100644
--- a/grademanagement-SpringProject/src/com/ssm/aop/xml/Log.java
+++ b/grademanagement-SpringProject/src/com/ssm/aop/xml/Log.java
@@ -9,6 +9,14 @@ public class Log {
String className = joinPoint.getTarget().getClass().getName();
// 获取目标方法名
String methodName = joinPoint.getSignature().getName();
+ // 获取方法参数
+ Object[] args = joinPoint.getArgs();
+ String argsInfo = "";
+ if (args != null && args.length > 0) {
+ argsInfo = ",参数:" + args[0];
+ }
System.out.println("前置通知:模拟日志记录...目标类是:" + className + ",被切入通知的目标方法为:" + methodName);
+
}
+
}
\ No newline at end of file
diff --git a/grademanagement-SpringProject/src/com/ssm/aop/xml/Test.java b/grademanagement-SpringProject/src/com/ssm/aop/xml/Test.java
index adc8bcf..4fe1af0 100644
--- a/grademanagement-SpringProject/src/com/ssm/aop/xml/Test.java
+++ b/grademanagement-SpringProject/src/com/ssm/aop/xml/Test.java
@@ -8,10 +8,20 @@ public class Test {
// 加载Spring配置文件
ApplicationContext ac = new ClassPathXmlApplicationContext("bean-aop-xml.xml");
- // 获取Department的Bean实例
+ // 获取Student的Bean实例
+ Student student = (Student) ac.getBean("student");
Department department = (Department) ac.getBean("department");
// 调用打印方法(AOP会自动切入前置通知)
+ student.printInfo();
department.printInfo();
+ // 获取公告服务Bean实例
+ Announcement service = (Announcement) ac.getBean("announcement");
+
+ // 调用业务方法(AOP会自动切入前置通知)
+ System.out.println("========== 测试发布公告 ==========");
+ service.printInfo();
+
+ System.out.println("\n========== 测试获取公告详情 ==========");
}
}
\ No newline at end of file