@Override public void updatePassword(AccountBean model, String newPassword) throws ServiceException { String msg = "Failed to update password. "; String account = model.getAccount(); if (VerifyTools.isBlank(account)) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (!StringTools.isPhone(account) && !StringTools.isEmail(account)) { log.error(msg + "account format error, expect phone or email: {}", account); throw new ServiceException(UserErrorCode.PHONE_OR_EMAIL_IS_REQUIRED); } if (VerifyTools.isBlank(newPassword)) { log.error(msg + "params is null: newPassword"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreBean user = findActivityUser(model); doUpdatePassword(model.getFactory(), model.getType(), user.getId(), newPassword); }
public static ValidatedAccount of(String id, AccountBean bean) { ValidatedAccount result = new ValidatedAccount(); result.setId(id); result.setFactory(bean.getFactory()); result.setType(bean.getType()); result.setAccount(bean.getAccount()); return result; } }
/** 根据用户工号查找用户,如果用户不存在则报错 **/ @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 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 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); } }
@Override public void repasswordByValidCode(AccountBean model, String validCode, String newPassword) throws ServiceException { String msg = "Failed to RepasswordByPhone. "; String account = model.getAccount(); if (VerifyTools.isBlank(account)) { log.error(msg + "params is null: account"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(newPassword)) { log.error(msg + "params is null: newPassword"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (StringTools.isPhone(account)) { smsValidCodeService.checkRepasswordValidCode(account, validCode, true); } else if (StringTools.isEmail(account)) { emailValidCodeService.checkRepasswordValidCode(account, validCode, true); } else { log.error(msg + "account format error, expect phone or email: {}", account); throw new ServiceException(UserErrorCode.PHONE_OR_EMAIL_IS_REQUIRED); } UserCoreBean user = findActivityUser(model); doUpdatePassword(model.getFactory(), model.getType(), user.getId(), newPassword); }
private UserCoreWhere toUserCoreWhere(AccountBean model) { String tenantCode = model.getFactory(); String account = model.getAccount(); UserCoreWhere where = new UserCoreWhere(); where.setTenantCode(tenantCode); // 根据登录账号的格式判断以哪种类型登录 if (StringTools.isPhone(account)) { where.setPhone(account); // 手机 } else if (StringTools.isEmail(account)) { where.setEmail(account); // 邮箱 } else { where.setUserCode(account); // 登录账号/工号 } return where; }
where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setUserName(model.getAccount());
where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setPhone(model.getAccount());
where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setEmail(model.getAccount());
where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); where.setUserCode(model.getAccount());
} else { model.setTenantCode(bean.getFactory()); model.setUserType(bean.getType()); String account = bean.getAccount();
where.setTenantCode(model.getFactory()); where.setUserType(model.getType()); if (StringTools.isPhone(account)) {