diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5c87c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# 编译输出目录 +out/ +target/ +build/ +*.class + +# IDE 配置 +.idea/ +*.iml +.vscode/ + +# 临时文件 +*.log +*.tmp +*.swp +*~ + +# 操作系统文件 +.DS_Store +Thumbs.db diff --git a/ffms-SpringProject/src/bean-aop.xml b/ffms-SpringProject/src/bean-aop.xml new file mode 100644 index 0000000..f3f39c6 --- /dev/null +++ b/ffms-SpringProject/src/bean-aop.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ffms-SpringProject/src/com/ssm/aop/xml/Income.java b/ffms-SpringProject/src/com/ssm/aop/xml/Income.java new file mode 100644 index 0000000..1b4b870 --- /dev/null +++ b/ffms-SpringProject/src/com/ssm/aop/xml/Income.java @@ -0,0 +1,59 @@ +package com.ssm.aop.xml; + +public class Income { + private Integer id; + private Integer userId; + private String type; + private double money; + private String incomeTime; + + public void printInfo(){ + System.out.println("=====籍美翎-收入信息====="); + System.out.println("收入ID:"+id); + System.out.println("用户ID:"+userId); + System.out.println("收入类型:"+type); + System.out.println("金额:"+money); + System.out.println("时间:"+incomeTime); + } + + // 必须加上 getter 和 setter,Spring 才能注入值 + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public double getMoney() { + return money; + } + + public void setMoney(double money) { + this.money = money; + } + + public String getIncomeTime() { + return incomeTime; + } + + public void setIncomeTime(String incomeTime) { + this.incomeTime = incomeTime; + } +} \ No newline at end of file diff --git a/ffms-SpringProject/src/com/ssm/aop/xml/Log.java b/ffms-SpringProject/src/com/ssm/aop/xml/Log.java new file mode 100644 index 0000000..a125efc --- /dev/null +++ b/ffms-SpringProject/src/com/ssm/aop/xml/Log.java @@ -0,0 +1,19 @@ +package com.ssm.aop.xml; + +import org.aspectj.lang.JoinPoint; +import java.util.Date; + +public class Log { + public void before(JoinPoint jp) { + System.out.println("=================================="); + System.out.println("【前置通知】开始执行方法:" + jp.getSignature().getName()); + System.out.println("【前置通知】执行时间:" + new Date()); + System.out.println("=================================="); + } + public void before(JoinPoint jp, String param) { + System.out.println("=================================="); + System.out.println("【前置通知】开始执行方法:" + jp.getSignature().getName()); + System.out.println("【前置通知】执行时间:" + new Date()); + System.out.println("=================================="); + } +} \ No newline at end of file diff --git a/ffms-SpringProject/src/com/ssm/aop/xml/StockAccount.java b/ffms-SpringProject/src/com/ssm/aop/xml/StockAccount.java new file mode 100644 index 0000000..78a0a79 --- /dev/null +++ b/ffms-SpringProject/src/com/ssm/aop/xml/StockAccount.java @@ -0,0 +1,64 @@ +package com.ssm.aop.xml; + +import java.math.BigDecimal; + +public class StockAccount { + private Integer id; + private Integer userId; + private String accountName; + private String broker; + private BigDecimal balance; + private String createDate; + + // 1. 必须有无参构造 + public StockAccount() {} + + // 2. 作业要求:printInfo方法,输出所有属性 + public void printInfo() { + System.out.println("\n=====于杉杉:证券账户信息====="); + System.out.println("账户ID:" + id); + System.out.println("所属用户ID:" + userId); + System.out.println("账户名称:" + accountName); + System.out.println("开户券商:" + broker); + System.out.println("账户余额:" + balance); + System.out.println("开户日期:" + createDate); + } + + // 3. 必须提供getter/setter + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getUserId() { + return userId; + } + public void setUserId(Integer userId) { + this.userId = userId; + } + public String getAccountName() { + return accountName; + } + public void setAccountName(String accountName) { + this.accountName = accountName; + } + public String getBroker() { + return broker; + } + public void setBroker(String broker) { + this.broker = broker; + } + public BigDecimal getBalance() { + return balance; + } + public void setBalance(BigDecimal balance) { + this.balance = balance; + } + public String getCreateDate() { + return createDate; + } + public void setCreateDate(String createDate) { + this.createDate = createDate; + } +} diff --git a/ffms-SpringProject/src/com/ssm/aop/xml/TestAop.java b/ffms-SpringProject/src/com/ssm/aop/xml/TestAop.java new file mode 100644 index 0000000..1665008 --- /dev/null +++ b/ffms-SpringProject/src/com/ssm/aop/xml/TestAop.java @@ -0,0 +1,16 @@ +package com.ssm.aop.xml; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class TestAop { + public static void main(String[] args) { + ApplicationContext ac = new ClassPathXmlApplicationContext("bean-aop.xml"); + User user = (User) ac.getBean("user"); + user.printInfo(); + StockAccount stockAccount = (StockAccount) ac.getBean("stockAccount"); + stockAccount.printInfo(); + Income income = (Income)ac.getBean("income"); + income.printInfo(); + } +} \ No newline at end of file diff --git a/ffms-SpringProject/src/com/ssm/aop/xml/User.java b/ffms-SpringProject/src/com/ssm/aop/xml/User.java new file mode 100644 index 0000000..c7fd800 --- /dev/null +++ b/ffms-SpringProject/src/com/ssm/aop/xml/User.java @@ -0,0 +1,67 @@ +package com.ssm.aop.xml; + +public class User { + private Integer id; + private String username; + private String userpass; + private String truename; + private String phone; + private String createTime; + + public void printInfo() { + System.out.println("===== 组长-用户信息 ====="); + System.out.println("ID:" + id); + System.out.println("用户名:" + username); + System.out.println("真实姓名:" + truename); + System.out.println("电话:" + phone); + System.out.println("注册时间:" + createTime); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getUserpass() { + return userpass; + } + + public void setUserpass(String userpass) { + this.userpass = userpass; + } + + public String getTruename() { + return truename; + } + + public void setTruename(String truename) { + this.truename = truename; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } +} \ No newline at end of file diff --git a/ffms-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java b/ffms-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java index 43c141c..e89f3f9 100644 --- a/ffms-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java +++ b/ffms-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java @@ -8,7 +8,7 @@ public class TestAnnotation { // 加载注解配置 ApplicationContext ac = new ClassPathXmlApplicationContext("bean-annotation.xml"); - // 只获取组长自己的 User + User user = (User) ac.getBean("user"); user.printInfo(); StockAccount stockAccount = (StockAccount) ac.getBean("stockAccount"); diff --git a/ffms-SpringProject/src/libs/aspectjweaver-1.9.6.jar b/ffms-SpringProject/src/libs/aspectjweaver-1.9.6.jar new file mode 100644 index 0000000..61277b6 Binary files /dev/null and b/ffms-SpringProject/src/libs/aspectjweaver-1.9.6.jar differ