fix
This commit is contained in:
@@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tailbet.model.entity.User;
|
||||
import com.tailbet.mapper.UserMapper;
|
||||
import com.tailbet.model.dto.UpdateUserDTO;
|
||||
import com.tailbet.openim.OpenIMClient;
|
||||
import com.tailbet.service.IUserService;
|
||||
import com.tailbet.util.JwtUtil;
|
||||
import com.tailbet.util.PasswordUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,11 +22,12 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUserService {
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
|
||||
|
||||
private final UserMapper userMapper;
|
||||
private final PasswordUtil passwordUtil;
|
||||
private final JwtUtil jwtUtil;
|
||||
private final OpenIMClient openIMClient;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUs
|
||||
* 注册用户
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public User register(String username, String password) {
|
||||
// 检查用户名是否已存在
|
||||
if (getByUsername(username) != null) {
|
||||
@@ -54,6 +58,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUs
|
||||
user.setStatus(1);
|
||||
userMapper.insert(user);
|
||||
|
||||
// 在OpenIM创建用户
|
||||
boolean openIMResult = openIMClient.createUser(String.valueOf(user.getId()), user.getNickname());
|
||||
if (!openIMResult) {
|
||||
log.warn("OpenIM用户创建失败: userId={}, username={}", user.getId(), username);
|
||||
throw new RuntimeException("OpenIM用户创建失败,请稍后再试!");
|
||||
}
|
||||
|
||||
// 分配运营(按最少绑定+优先在线算法)
|
||||
assignOps(user);
|
||||
|
||||
@@ -79,7 +90,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUs
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user