@Override public String getId() { return original.getId(); }
if (user instanceof UserCoreBean.Wrap) { UserCoreBean bean = ((UserCoreBean.Wrap) user).original(); map.put(bean.getId(), bean);
private UserCoreBean findUser(UserCoreWhere where, String password, String msg) throws ServiceException { UserCoreBean user; try { user = userCoreBasic.find(where); } catch (Exception e) { log.error(msg + "{}. {}", e.toString(), JsonTools.toJsonString(where)); throw new ServiceException(UserErrorCode.USERINFO_LOGIN_ERROR, e); } if (user == null) { log.warn(msg + "{}. {}", "user not found", JsonTools.toJsonString(where)); throw new ServiceException(UserErrorCode.USER_NOT_EXIST); } // 判断密码是否匹配 if (VerifyTools.isBlank(password) || passwordService.validate(user.getId(), password, user.getPassword())) { return user; } else { // 密码不匹配 log.warn(msg + "{}. {}", "password error", JsonTools.toJsonString(where)); throw new ServiceException(UserErrorCode.USER_LOGIN_PASSWORD_ERROR); } }
if (VerifyTools.isBlank(model.getId())) { model.setId(sequenceGenerator.generate(UserCoreBean.TABLE));
@Override public void delete(UserCoreWhere where, IAccount me) throws ServiceException { String msg = "Failed to delete UserCore. "; if (VerifyTools.isBlank(me)) { log.error(msg + "params is null: me"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (VerifyTools.isBlank(where)) { log.error(msg + "params is null: where"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } Set<String> temp = new HashSet<>(); { // 根据条件查询UserId PageList<UserCoreBean> PageList = userCoreBasic.list(where, OrderPaging.NONE); if (VerifyTools.isBlank(PageList)) { return; } for (UserCoreBean user : PageList) { temp.add(user.getId()); } } List<String> ids = new ArrayList<>(temp); // 删除用户角色关联 UserRoleRefWhere rw = new UserRoleRefWhere(); rw.setUserIds(ids); userRoleRefBasic.delete(rw, false); // 删除sys_user_core_info表的记录 userCoreBasic.deleteByIds(ids, false); }
if (VerifyTools.isBlank(model.getId())) { model.setId(sequenceGenerator.generate(UserCoreBean.TABLE));
@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); }
break; } else { // 判断密码是否匹配 if (passwordService.validate(u.getId(), password, u.getPassword())) { user = u; break;
@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); }
if (!bean.getId().equals(userId)) { log.error("UserName[{}] has registered.", model.getAccount()); throw new ServiceException(UserErrorCode.USER_HAS_REGISTER);
if (!bean.getId().equals(userId)) { log.error("Email[{}] has registered.", model.getAccount()); throw new ServiceException(UserErrorCode.EMAIL_HAS_REGISTER);
if (!bean.getId().equals(userId)) { log.error("UserCode[{}] has registered.", model.getAccount()); throw new ServiceException(UserErrorCode.USER_HAS_REGISTER);
if (!bean.getId().equals(userId)) { log.error("Phone[{}] has registered.", model.getAccount()); throw new ServiceException(UserErrorCode.PHONE_HAS_REGISTER);
where.setId(user.getId()); UserCoreUpdate update = new UserCoreUpdate(); update.setWhere(where);