|
|
|
|
@ -0,0 +1,84 @@
|
|
|
|
|
package com.ssm.di.annotation;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 院系实体类(注解版DI实现)
|
|
|
|
|
* 任务要求:com.ssm.di.annotation 包下
|
|
|
|
|
*/
|
|
|
|
|
// 1. 标记为Spring容器管理的Bean,名称为 "department"
|
|
|
|
|
@Component("department")
|
|
|
|
|
public class Department {
|
|
|
|
|
// 2. 使用@Value注入属性,替代XML中的property
|
|
|
|
|
@Value("1001")
|
|
|
|
|
private Integer deptId; // 院系ID
|
|
|
|
|
|
|
|
|
|
@Value("计算机学院")
|
|
|
|
|
private String deptName; // 院系名称
|
|
|
|
|
|
|
|
|
|
@Value("CS-2026")
|
|
|
|
|
private String deptNo; // 院系编号
|
|
|
|
|
|
|
|
|
|
@Value("李院长")
|
|
|
|
|
private String deptManager; // 院系负责人
|
|
|
|
|
|
|
|
|
|
@Value("010-88889999")
|
|
|
|
|
private String deptPhone; // 联系电话
|
|
|
|
|
|
|
|
|
|
@Value("主校区")
|
|
|
|
|
private String campus; // 所属校区
|
|
|
|
|
|
|
|
|
|
// 3. 无参构造(Spring IoC 实例化必须保留)
|
|
|
|
|
public Department() {}
|
|
|
|
|
|
|
|
|
|
// 4. Getter & Setter (Spring依赖注入必须)
|
|
|
|
|
public Integer getDeptId() { return deptId; }
|
|
|
|
|
public void setDeptId(Integer deptId) { this.deptId = deptId; }
|
|
|
|
|
|
|
|
|
|
public String getDeptName() { return deptName; }
|
|
|
|
|
public void setDeptName(String deptName) { this.deptName = deptName; }
|
|
|
|
|
|
|
|
|
|
public String getDeptNo() { return deptNo; }
|
|
|
|
|
public void setDeptNo(String deptNo) { this.deptNo = deptNo; }
|
|
|
|
|
|
|
|
|
|
public String getDeptManager() { return deptManager; }
|
|
|
|
|
public void setDeptManager(String deptManager) { this.deptManager = deptManager; }
|
|
|
|
|
|
|
|
|
|
public String getDeptPhone() { return deptPhone; }
|
|
|
|
|
public void setDeptPhone(String deptPhone) { this.deptPhone = deptPhone; }
|
|
|
|
|
|
|
|
|
|
public String getCampus() { return campus; }
|
|
|
|
|
public void setCampus(String campus) { this.campus = campus; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 5. 自定义printInfo方法:控制台打印院系信息
|
|
|
|
|
*/
|
|
|
|
|
public void printInfo() {
|
|
|
|
|
System.out.println("===== 【院系管理】信息 =====");
|
|
|
|
|
System.out.println("院系ID : " + deptId);
|
|
|
|
|
System.out.println("院系名称 : " + deptName);
|
|
|
|
|
System.out.println("院系编号 : " + deptNo);
|
|
|
|
|
System.out.println("负责人 : " + deptManager);
|
|
|
|
|
System.out.println("联系电话 : " + deptPhone);
|
|
|
|
|
System.out.println("所属校区 : " + campus);
|
|
|
|
|
System.out.println("==========================\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 6. 重写toString方法(方便测试打印)
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return "Department{" +
|
|
|
|
|
"deptId=" + deptId +
|
|
|
|
|
", deptName='" + deptName + '\'' +
|
|
|
|
|
", deptNo='" + deptNo + '\'' +
|
|
|
|
|
", deptManager='" + deptManager + '\'' +
|
|
|
|
|
", deptPhone='" + deptPhone + '\'' +
|
|
|
|
|
", campus='" + campus + '\'' +
|
|
|
|
|
'}';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|