Пример #1
0
 @Override
 public String execute(HttpServletRequest request, HttpServletResponse response) {
   String login = request.getParameter("name");
   String password = request.getParameter("password");
   Authorization au = new Authorization();
   au.setLogin(login);
   au.setPassword(password);
   DaoFactory factory = DaoFactory.getDaoFactory();
   AuthorizationDao udao = factory.getAuthorizationDao();
   StaffDao sdao = factory.getStaffDao();
   DepartmentDao ddao = factory.getDepartmentDao();
   PatientDao pdao = factory.getPatientDao();
   if (udao.isAuthorization(au)) {
     HttpSession session = request.getSession(true);
     Authorization forSession = udao.readByLogin(login);
     Staff forAccess = sdao.readById(forSession.getStaff());
     String fa = forAccess.getSpecialization();
     session.setAttribute("access", fa);
     if (session.getAttribute("access").equals("admin")) {
       List<Department> departments = ddao.getAllDepartments();
       request.setAttribute("departments", departments);
       return "/views/adminUserInformation.jsp";
     } else if (session.getAttribute("access").equals("doctor")) {
       return "/views/doctorStartPage.html";
     } else if (session.getAttribute("access").equals("nurse")) {
       List<Patient> patients = pdao.getAllPatients();
       request.setAttribute("patients", patients);
       return "/views/nurseStart.jsp";
     } else {
       return "/views/test.html";
     }
   } else {
     return "../index.html";
   }
 }
Пример #2
0
 private String newStaffId(String position) {
   if (position.equals("管理员")) {
     List<Staff> list = staffDao.findByPosition(position);
     int num = list.size() + 1;
     String id = "";
     if (num < 10) {
       id = "S" + "000" + num;
     } else if (100 > num && num >= 10) {
       id = "S" + "00" + num;
     } else if (1000 > num && num >= 100) {
       id = "S" + "0" + num;
     } else {
       id = "S" + num;
     }
     return id;
   } else if (position.equals("经理")) {
     List<Staff> list = staffDao.findByPosition(position);
     int num = list.size() + 1;
     String id = "";
     if (num < 10) {
       id = "A" + "000" + num;
     } else if (100 > num && num >= 10) {
       id = "A" + "00" + num;
     } else if (1000 > num && num >= 100) {
       id = "A" + "0" + num;
     } else {
       id = "A" + num;
     }
     return id;
   } else {
     List<Staff> list = staffDao.findByPosition(position);
     int num = list.size() + 1;
     String id = "";
     if (num < 10) {
       id = "C" + "000" + num;
     } else if (100 > num && num >= 10) {
       id = "C" + "00" + num;
     } else if (1000 > num && num >= 100) {
       id = "C" + "0" + num;
     } else {
       id = "C" + num;
     }
     return id;
   }
 }
Пример #3
0
  @Override
  public boolean login(String staffid, String password) {
    Staff staff = staffDao.findByStaffId(staffid);
    if (staff == null) {
      return false;
    }

    if (password.equals(staff.getPassword())) return true;
    else return false;
  }
Пример #4
0
  @Override
  public StaffInfo searchStaffByStaffid(String staffid) {
    StaffInfo staff = new StaffInfo();
    Staff staffentity = staffDao.findByStaffId(staffid);

    if (staffentity != null) {
      staff = convertEntity(staffentity);
    }

    return staff;
  }
Пример #5
0
  @Override
  public List<StaffInfo> searchStaffByProposition(String position) {
    List<StaffInfo> stafflist = new ArrayList<StaffInfo>();
    List<Staff> entitylist = staffDao.findByPosition(position);

    if (entitylist != null) {
      for (int i = 0; i < entitylist.size(); i++) {
        StaffInfo temp = convertEntity(entitylist.get(i));
        stafflist.add(temp);
      }
    }

    return stafflist;
  }
Пример #6
0
  @Override
  public List<StaffInfo> getStaffList() {
    List<StaffInfo> stafflist = new ArrayList<StaffInfo>();
    List<Staff> entitylist = staffDao.findAll();

    if (entitylist != null) {
      for (int i = 0; i < entitylist.size(); i++) {
        StaffInfo temp = convertEntity(entitylist.get(i));
        stafflist.add(temp);
      }
    }

    return stafflist;
  }
Пример #7
0
 @Override
 public void deleteStaff(StaffInfo staffinfo) {
   Staff staff = convertInfo(staffinfo);
   staffDao.delete(staff);
 }
Пример #8
0
 @Override
 public void modifyStaffInfo(StaffInfo staffinfo) {
   Staff staff = convertInfo(staffinfo);
   staffDao.modify(staff);
 }
Пример #9
0
 @Override
 public void addNewStaff(StaffInfo staffinfo) {
   Staff staff = convertInfo(staffinfo);
   staff.setStaffid(newStaffId(staffinfo.getPosition()));
   staffDao.create(staff);
 }