use of org.neusoft.neubbs.entity.UserActionDO in project neubbs by nuitcoder.
the class UserActionDAOTest method saveTestUserActionDOToDatabase.
/**
* 保存测试 UserActionDO 对象至数据库
* - 新建测试用户
* - 保存,且重新查询数据库获得对象(根据用户 id,进行查询)
*
* @return UserActionDO 用户行为对象
*/
private UserActionDO saveTestUserActionDOToDatabase() {
UserDO user = new UserDO();
user.setName("testUser");
user.setPassword(SecretUtil.encryptMd5(SecretUtil.encryptMd5("123456") + "123456"));
user.setEmail("testUser@neubbs.com");
Assert.assertEquals(1, userDAO.saveUser(user));
UserActionDO userAction = new UserActionDO();
userAction.setUserId(user.getId());
Assert.assertEquals(1, userActionDAO.saveUserAction(userAction));
return userActionDAO.getUserAction(user.getId());
}
use of org.neusoft.neubbs.entity.UserActionDO 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