// 登陆 public String login() { // 先从session中取empModel EmpModel loginEmp = null; loginEmp = getLogin(); if (loginEmp == null) { // 添加登陆ip(lastLoginIp) HttpServletRequest request = ServletActionContext.getRequest(); String loginIp = request.getHeader("x-forwarded-for"); if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) { loginIp = request.getHeader("Proxy-Client-IP"); } if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) { loginIp = request.getHeader("WL-Proxy-Client-IP"); } if (loginIp == null || loginIp.length() == 0 || "unknown".equalsIgnoreCase(loginIp)) { loginIp = request.getRemoteAddr(); } // 根据业务层查询登陆的用户,用户名/密码是否正确 loginEmp = empEbi.login(emp.getUserName(), emp.getPwd(), loginIp); } // 判断是否查到用户 if (loginEmp != null) { // 将用户信息放入session中 putSession(EmpModel.LOGIN_EMP_INFO, loginEmp); return "loginSuccess"; } else { // 添加错误提示信息 this.addActionError("用户名/密码错误!"); return "loginFail"; } }
public String changePwd() { // // 从session中获取emp EmpModel em = (EmpModel) get(EmpModel.LOGIN_EMP_INFO); put(EmpModel.LOGIN_EMP_INFO, null); empEbi.changePwd(em.getUserName(), em.getPwd(), newPwd); return "loginFail"; }
public String save() { // 判断是否有uuid if (emp.getUuid() != null) { // 调用业务层更新 empEbi.update(emp); } else { empEbi.save(emp, roleUuids); } return TOLIST; }
// 修改 public String input() { List<DepModel> depList = depEbi.getAll(); put("depList", depList); // 查询角色列表 List<RoleModel> roleList = roleEbi.getAll(); put("roleList", roleList); // 新建/修改:判断是否有uuid if (emp.getUuid() != null) { emp = empEbi.getByUuid(emp.getUuid()); // roleUuids初始化为空 // TODO checklist name 属性 必须是数组 // 下面这段代码的主要作用:用于checklist的回显 roleUuids = new Long[roleList.size()]; int i = 0; for (RoleModel rm : roleList) { roleUuids[i++] = rm.getUuid(); } } return INPUT; }