private UserCoreBean findActivityUser(AccountBean model, String password, IAccountType... choose) throws ServiceException { String msg = "Failed to find activity user. "; if (VerifyTools.isBlank(model.getAccount())) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(model.getType())) { log.error(msg + "params is null: AccountType"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 合并model中的AccountType和choose List<IAccountType> types = concatAccountType(model.getType(), choose); // 查找用户 UserCoreWhere where = toUserCoreWhere(model); UserCoreBean user; if (types.size() == 0) { user = findUser(where, password, msg); } else if (types.size() == 1) { where.setUserType(types.get(0)); user = findUser(where, password, msg); } else { where.setUserTypes(types); user = chooseUser(where, password, msg); } // 判断用户状态 checkUserState(user); user.setPassword(null); // 清空密码 return user; }
private void doUpdatePassword(String factory, IAccountType userType, String userId, String newPassword) throws ServiceException { // 密码加密 String hashPassword = passwordService.create(userId, newPassword); UserCoreUpdate ud = new UserCoreUpdate(); ud.setPassword(hashPassword); UserCoreWhere where = ud.getWhere(true); where.setTenantCode(factory); where.setUserType(userType); where.setId(userId); userCoreBasic.update(ud, true); }
/** 根据手机号码查找用户,如果用户不存在则报错 **/ @Override public UserCoreBean findByPhoneThrowOnNotExists(AccountBean model) throws ServiceException { String msg = "Failed to FindUserByPhone. "; if (VerifyTools.isBlank(model)) { log.error(msg + "params is null: model"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(model.getAccount())) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setPhone(model.getAccount()); UserCoreBean user = userCoreBasic.find(where); if (user != null) { return user; } else { log.error(msg + "user info not found, phone={}", model.getAccount()); throw new ServiceException(UserErrorCode.USER_NOT_EXIST); } }
/** 根据用户工号查找用户,如果用户不存在则报错 **/ @Override public UserCoreBean findByUserCodeThrowOnNotExists(AccountBean model) throws ServiceException { String msg = "Failed to FindUserByUserCode. "; if (VerifyTools.isBlank(model)) { log.error(msg + "params is null: model"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(model.getAccount())) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setUserCode(model.getAccount()); UserCoreBean user = userCoreBasic.find(where); if (user != null) { return user; } else { log.error(msg + "user info not found, UserCode={}", model.getAccount()); throw new ServiceException(UserErrorCode.USER_NOT_EXIST); } }
/** 根据邮箱地址查找用户,如果用户不存在则报错 **/ @Override public UserCoreBean findByEmailThrowOnNotExists(AccountBean model) throws ServiceException { String msg = "Failed to FindUserByEmail. "; if (VerifyTools.isBlank(model)) { log.error(msg + "params is null: model"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(model.getAccount())) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setEmail(model.getAccount()); UserCoreBean user = userCoreBasic.find(where); if (user != null) { return user; } else { log.error(msg + "user info not found, email={}", model.getAccount()); throw new ServiceException(UserErrorCode.USER_NOT_EXIST); } }
/** 根据用户登录名查找用户,如果用户不存在则报错 **/ @Override public UserCoreBean findByUserNameThrowOnNotExists(AccountBean model) throws ServiceException { String msg = "Failed to FindUserByUserName. "; if (VerifyTools.isBlank(model)) { log.error(msg + "params is null: model"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(model.getAccount())) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setUserName(model.getAccount()); UserCoreBean user = userCoreBasic.find(where); if (user != null) { return user; } else { log.error(msg + "user info not found, UserName={}", model.getAccount()); throw new ServiceException(UserErrorCode.USER_NOT_EXIST); } }
where.setUserType(model.getType()); where.setUserName(model.getAccount());
where.setUserType(model.getType()); where.setPhone(model.getAccount());
where.setUserType(model.getType()); where.setEmail(model.getAccount());
where.setUserType(model.getType()); where.setUserCode(model.getAccount());
UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(cu.getFactory()); where.setUserType(userType); where.setId(cu.getId()); user = userCoreQueryer.find(where);
where.setUserType(model.getType()); if (StringTools.isPhone(account)) { where.setPhone(account);