程序中不应对身份证号码进行硬编码,可以使用配置文件或数据库存储的方式来存储系统所需的数据;并且录入数据时,还可以做加密处理之后再进行数据的录入,从而防止敏感数据泄露。

    1. public class EmployeeDAO {
    2. private static Map<Integer, Employee> emps = new LinkedHashMap<Integer, Employee>();
    3. //...
    4. static {
    5. emps.put(1001, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1001)), "韩信", 32, EncryptUtil.encrypt(phoneDAO.getPhoneById(1001), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
    6. emps.put(1002, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1002)), "张良", 40, EncryptUtil.encrypt(phoneDAO.getPhoneById(1002), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
    7. emps.put(1003, new Employee(EncryptUtil.encrypt(idCardDAO.getIdByUserId(1003)), "萧何", 28, EncryptUtil.encrypt(phoneDAO.getPhoneById(1003), EncryptUtil.encrypt(bankCardDAO.getIdByUserId(1001))));
    8. // ...
    9. }
    10. // 雇员信息的增删改查方法
    11. // ...
    12. }
    13. public class Employee {
    14. private String id; // 记录雇员的身份证号码
    15. private String name;
    16. private int age;
    17. private String tel; // 记录雇员的电话号码
    18. private String bankId; // 记录雇员的银行卡卡号
    19. public Employee() {}
    20. public Employee(String id, String name, int age, String tel, String bankId) {
    21. this.id = id;
    22. this.name = name;
    23. this.age = age;
    24. this.tel = tel;
    25. this.bankId = bankId;
    26. }
    27. // Getter and Setter
    28. // ...
    29. }