public boolean alreadyUsedName(UserVO userVO) { UserVO user = userDAO.queryUserByName(userVO.getUserName()); if (user != null) { return true; } else { return false; } }
/** * 登录验证 * * @param account 帐号,可以是帐号、email、手机号 * @param password 密码 * @return resultVO */ public ResultVO login(String account, String password) { ResultVO resultVO = new ResultVO(); UserVO userVO = userDAO.queryUserByCodeOrEmailOrPhone(account); if (userVO == null) { resultVO = new ResultVO("账号或密码错误"); } else { if (!password.equals(userVO.getPassword())) { resultVO = new ResultVO("账号或密码错误"); } } EnvironmentInfoVO objEnvironmentInfoVO = new EnvironmentInfoVO(); objEnvironmentInfoVO.setUser(userVO); WebContext objWebContext = WebContextFactory.get(); objWebContext.getSession().setAttribute("environmentInfo", objEnvironmentInfoVO); if (resultVO.isSuccess()) { objWebContext.getSession().setAttribute("current_user", userVO); } return resultVO; }
/** * 注册 * * @param userVO 用户信息 */ public void regist(UserVO userVO) { // 注册赠送10积分 userVO.setScore(10); userDAO.insertUser(userVO); }
/** * 查询用户,根据帐号或者email或者phone * * @param account * @return */ public UserVO getUser(String account) { return userDAO.queryUserByCodeOrEmailOrPhone(account); }