程序中不应对身份证号码进行硬编码,可以使用配置文件或数据库存储的方式来存储系统所需的数据;并且录入数据时,还可以做加密处理之后再进行数据的录入,从而防止敏感数据泄露。
public class EmployeeDAO {
private static Map<Integer, Employee> emps = new LinkedHashMap<Integer, Employee>();
//...
static {
emps.put(1001, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1001)), "韩信", 32, EncryptUtil.encrypt(phoneDAO.getPhoneById(1001), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
emps.put(1002, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1002)), "张良", 40, EncryptUtil.encrypt(phoneDAO.getPhoneById(1002), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
emps.put(1003, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1003)), "萧何", 28, EncryptUtil.encrypt(phoneDAO.getPhoneById(1003), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
// ...
}
// 雇员信息的增删改查方法
// ...
}
public class Employee {
private String id; // 记录雇员的身份证号码
private String name;
private int age;
private String tel; // 记录雇员的电话号码
private String bankId; // 记录雇员的银行卡卡号
public Employee() {}
public Employee(String id, String name, int age, String tel, String bankId) {
this.id = id;
this.name = name;
this.age = age;
this.tel = tel;
this.bankId = bankId;
}
// Getter and Setter
// ...
}