|
|
@ -16,9 +16,7 @@ import com.bx.implatform.config.props.JwtProperties; |
|
|
import com.bx.implatform.dto.LoginDTO; |
|
|
import com.bx.implatform.dto.LoginDTO; |
|
|
import com.bx.implatform.dto.ModifyPwdDTO; |
|
|
import com.bx.implatform.dto.ModifyPwdDTO; |
|
|
import com.bx.implatform.dto.RegisterDTO; |
|
|
import com.bx.implatform.dto.RegisterDTO; |
|
|
import com.bx.implatform.entity.Friend; |
|
|
import com.bx.implatform.entity.*; |
|
|
import com.bx.implatform.entity.GroupMember; |
|
|
|
|
|
import com.bx.implatform.entity.User; |
|
|
|
|
|
import com.bx.implatform.enums.ResultCode; |
|
|
import com.bx.implatform.enums.ResultCode; |
|
|
import com.bx.implatform.exception.GlobalException; |
|
|
import com.bx.implatform.exception.GlobalException; |
|
|
import com.bx.implatform.mapper.UserMapper; |
|
|
import com.bx.implatform.mapper.UserMapper; |
|
|
@ -29,9 +27,7 @@ import com.bx.implatform.session.UserSession; |
|
|
import com.bx.implatform.util.BeanUtils; |
|
|
import com.bx.implatform.util.BeanUtils; |
|
|
import com.bx.implatform.util.IpUtils; |
|
|
import com.bx.implatform.util.IpUtils; |
|
|
import com.bx.implatform.util.SensitiveFilterUtil; |
|
|
import com.bx.implatform.util.SensitiveFilterUtil; |
|
|
import com.bx.implatform.vo.LoginVO; |
|
|
import com.bx.implatform.vo.*; |
|
|
import com.bx.implatform.vo.OnlineTerminalVO; |
|
|
|
|
|
import com.bx.implatform.vo.UserVO; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -61,6 +57,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
private UserLabelService userLabelService; |
|
|
private UserLabelService userLabelService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserGroupService UserGroupService; |
|
|
private UserGroupService UserGroupService; |
|
|
|
|
|
private final UserGroupService userGroupService; // 注入 UserGroupService
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private UserLabelService UserLabelService;
|
|
|
|
|
|
private final UserLabelService UserLabelService; // 注入 UserGroupService
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
// @Override
|
|
|
// public LoginVO login(LoginDTO dto) {
|
|
|
// public LoginVO login(LoginDTO dto) {
|
|
|
@ -341,6 +341,104 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
return vo; |
|
|
return vo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public UserVO getGroup(Long id) { |
|
|
|
|
|
User user = this.getById(id); |
|
|
|
|
|
if (user == null) { |
|
|
|
|
|
throw new GlobalException(ResultCode.PROGRAM_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UserVO vo = BeanUtils.copyProperties(user, UserVO.class); |
|
|
|
|
|
|
|
|
|
|
|
// 获取用户的分组信息并转换为VO
|
|
|
|
|
|
String token = user.getUniqueToken(); |
|
|
|
|
|
if (StringUtils.hasText(token)) { |
|
|
|
|
|
List<UserGroup> groups = userGroupService.getGroupList(token); |
|
|
|
|
|
|
|
|
|
|
|
// 转换为UserGroupVO
|
|
|
|
|
|
List<UserGroupVO> groupVOList = groups.stream() |
|
|
|
|
|
.map(g -> new UserGroupVO(g.getId(), g.getGroupName())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
vo.setGroupList(groupVOList); |
|
|
|
|
|
|
|
|
|
|
|
// 设置分组名称列表
|
|
|
|
|
|
List<String> groupNames = groups.stream() |
|
|
|
|
|
.map(UserGroup::getGroupName) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
} else { |
|
|
|
|
|
vo.setGroupList(new ArrayList<>()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return vo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public UserVO getLabe(Long id) { |
|
|
|
|
|
User user = this.getById(id); |
|
|
|
|
|
if (user == null) { |
|
|
|
|
|
throw new GlobalException(ResultCode.PROGRAM_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UserVO vo = BeanUtils.copyProperties(user, UserVO.class); |
|
|
|
|
|
|
|
|
|
|
|
// 获取用户的分组信息并转换为VO
|
|
|
|
|
|
String token = user.getUniqueToken(); |
|
|
|
|
|
if (StringUtils.hasText(token)) { |
|
|
|
|
|
List<UserLabel> label = UserLabelService.getLabelList(token); |
|
|
|
|
|
|
|
|
|
|
|
// 转换为UserGroupVO
|
|
|
|
|
|
List<UserLabelVO> labelVOList = label.stream() |
|
|
|
|
|
.map(g -> new UserLabelVO(g.getId(), g.getLabelName())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
vo.setLabelList(labelVOList); |
|
|
|
|
|
|
|
|
|
|
|
// 设置标签名称列表
|
|
|
|
|
|
List<String> labelNames = label.stream() |
|
|
|
|
|
.map(UserLabel::getLabelName) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
} else { |
|
|
|
|
|
vo.setLabelList(new ArrayList<>()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return vo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void saveUserGroup(Long userId, String groupId) { |
|
|
|
|
|
// 获取目标用户
|
|
|
|
|
|
User targetUser = this.getById(userId); |
|
|
|
|
|
if (ObjectUtil.isNull(targetUser)) { |
|
|
|
|
|
throw new GlobalException(ResultCode.PROGRAM_ERROR); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 设置分组ID
|
|
|
|
|
|
targetUser.setGroupIds(groupId); |
|
|
|
|
|
|
|
|
|
|
|
// 更新用户信息到数据库
|
|
|
|
|
|
boolean updated = this.updateById(targetUser); |
|
|
|
|
|
|
|
|
|
|
|
if (!updated) { |
|
|
|
|
|
throw new GlobalException(ResultCode.PROGRAM_ERROR, "更新用户分组失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.info("用户 {} 的分组已更新为: {}", userId, groupId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void saveUserLabel(Long userId, String labelIds) { |
|
|
|
|
|
User user = this.getById(userId); |
|
|
|
|
|
log.info("用户 {} 的分组已更新为: {}", userId, labelIds); |
|
|
|
|
|
if (ObjectUtil.isNull(user)) { |
|
|
|
|
|
throw new GlobalException(ResultCode.PROGRAM_ERROR, "用户不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
// 保存标签ID串
|
|
|
|
|
|
user.setLabelIds(labelIds); |
|
|
|
|
|
this.updateById(user); |
|
|
|
|
|
log.info("用户{}标签保存成功: {}", userId, labelIds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<UserVO> findUserByName(String name) { |
|
|
public List<UserVO> findUserByName(String name) { |
|
|
LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
|
|
LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery(); |
|
|
|