日期:2014-05-19 浏览次数:20837 次
public class Employee implements java.io.Serializable { // Fields private static final long serialVersionUID = 5106663630382037556L; private String sn; private Position position; private Department department; private String password; private String name; private String status; // Constructors /** default constructor */ public Employee() { } // Property accessors /** * @return 工号 */ public String getSn() { return this.sn; } public void setSn(String sn) { this.sn = sn; } /** * @return 职务 */ public Position getPosition() { return this.position; } public void setPosition(Position position) { this.position = position; } /** * @return 部门 */ public Department getDepartment() { return this.department; } public void setDepartment(Department department) { this.department = department; } /** * @return 密码 */ public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } /** * @return 姓名 */ public String getName() { return this.name; } public void setName(String name) { this.name = name; } /** * @return 状态 */ public String getStatus() { return this.status; } public void setStatus(String status) { this.status = status; } }
/** * 用户登录action * @author 北大青鸟 * @version 1.0 */ public class UserAction extends ActionSupport { private static final long serialVersionUID = 1L; private final Log logger = LogFactory.getLog(getClass()); private Employee employee; private EmployeeService employeeService; /** * 用户登录。 * @return * @throws Exception */ public String login() throws Exception { Employee newEmployee = null; try { System.out.println(employee.getName()); employee.setPassword(new MD5(employee.getPassword()).compute()); newEmployee = employeeService.login(employee); if (logger.isDebugEnabled()) { logger.debug("---------------" + newEmployee.getName()); } } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } String ret = INPUT; if (newEmployee == null) { ret = INPUT; } else { ActionContext ac = ActionContext.getContext(); ac.getSession().put("employee", newEmployee); //获取职员职务信息,并获得职务名称 String nameCn = newEmployee.getPosition().getNameCn(); if ("员工".equals(nameCn)) { ret = "staff"; ClaimVoucher claimVoucher = new ClaimVoucher(); claimVoucher.setStatus(Constants.CLAIMVOUCHER_CREATED); claimVoucher.setId(0); ac.getSession().put("claimVoucher", claimVoucher); } else if ("部门经理".equals(nameCn)) { ret = "deptManager"; } else if ("总经理".equals(nameCn)) { ret = "manager"; } else if ("财务".equals(nameCn)) { ret = "cashier"; } } return ret; } //其他get/set方法省略 }