use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class UserServiceImpl method registerUser.
@Override
public UserDO registerUser(String username, String password, String email) {
// judge username, email is occupied
this.confirmUserNotOccupiedByUsername(username);
this.confirmUserNotOccupiedByEmail(email);
// build UserDO, UserActionDO
UserDO user = new UserDO();
user.setName(username);
user.setEmail(email);
user.setPassword(this.encryptUserPassword(password));
UserActionDO userAction = new UserActionDO();
// insert forum_user, forum_user_action
if (userDAO.saveUser(user) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.US1);
}
userAction.setUserId(user.getId());
if (userActionDAO.saveUserAction(userAction) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.US33);
}
// update forum_user 'fu_avator', set default avatar
if (userDAO.updateUserAvatorByName(user.getName(), ParamConst.USER_DEFAULT_IMAGE) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.US2);
}
// re-query user information
return this.getUserInfoById(user.getId());
}
Aggregations