Search in sources :

Example 16 with ServiceException

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());
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) ServiceException(org.neusoft.neubbs.exception.ServiceException) UserDO(org.neusoft.neubbs.entity.UserDO)

Aggregations

ServiceException (org.neusoft.neubbs.exception.ServiceException)16 TopicCategoryDO (org.neusoft.neubbs.entity.TopicCategoryDO)3 UserDO (org.neusoft.neubbs.entity.UserDO)3 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)2 TopicDO (org.neusoft.neubbs.entity.TopicDO)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 TopicActionDO (org.neusoft.neubbs.entity.TopicActionDO)1 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)1 UserActionDO (org.neusoft.neubbs.entity.UserActionDO)1