if (cacheService.exist(AREA_DIVISION_KEY, scene)) {
public void checkChangeEmailValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckChangePhoneCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (!cache.exist(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), email); } }
public void checkLoginValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckLoginCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_LOGIN.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_LOGIN.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_LOGIN.name(), email); } }
public void checkChangePhoneValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckChangePhoneCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (!cache.exist(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), phone); } }
public void checkRepasswordValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRepasswordCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REPASSWORD.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REPASSWORD.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), phone); } }
public void checkRegisterValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRegisterCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REGISTER.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REGISTER.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REGISTER.name(), phone); } }
public void checkRegisterValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRegisterCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REGISTER.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REGISTER.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REGISTER.name(), email); } }
public void checkRepasswordValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRepasswordCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REPASSWORD.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REPASSWORD.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), email); } }
public void checkLoginValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckLoginCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_LOGIN.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_LOGIN.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_LOGIN.name(), phone); } }
@Override public List<KeyString> listAreaText(String scene, List<String> areaCodes) throws ServiceException { if (VerifyTools.isBlank(scene)) { log.error("params is null: SceneType"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(areaCodes)) { return null; } Map<String, AreaBean> map; if (cacheService.exist(AREA_DIVISION_KEY, scene)) { // 从缓存中查询 map = cacheService.haget(AREA_DIVISION_KEY, scene, AreaBean.class); } else { // 从数据库查询 PageList<AreaDivisionBean> temp = listAllFromDb(scene); if (temp == null) { return null; } else { List<AreaDivisionBean> list = temp.toList(); map = new HashMap<>(); for (AreaBean bean : list) { map.put(bean.getAreaCode(), bean.to(AreaBean.class)); } // 放入缓存 cacheService.hmset(AREA_DIVISION_KEY, scene, map); } } return AreaDivisionTools.getAreaText(areaCodes, map); }