|
@@ -0,0 +1,72 @@
|
|
|
+package com.zhentao.shouye.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zhentao.shouye.domain.Groups;
|
|
|
+import com.zhentao.shouye.domain.UserShouye;
|
|
|
+import com.zhentao.shouye.dto.UserShouyeDto;
|
|
|
+import com.zhentao.shouye.service.GroupsService;
|
|
|
+import com.zhentao.shouye.service.UserShouyeService;
|
|
|
+import com.zhentao.shouye.mapper.UserShouyeMapper;
|
|
|
+import com.zhentao.user.domain.UserLogin;
|
|
|
+import com.zhentao.user.service.UserLoginService;
|
|
|
+import com.zhentao.vo.Result;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.xml.ws.Action;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @author 86183
|
|
|
+* @description 针对表【user_shouye(用户首页表)】的数据库操作Service实现
|
|
|
+* @createDate 2025-06-04 19:44:02
|
|
|
+*/
|
|
|
+@Service
|
|
|
+public class UserShouyeServiceImpl extends ServiceImpl<UserShouyeMapper, UserShouye>
|
|
|
+ implements UserShouyeService{
|
|
|
+ @Autowired
|
|
|
+ private UserLoginService userLoginService;
|
|
|
+ @Autowired
|
|
|
+ private GroupsService groupsService;
|
|
|
+ public static boolean isLongNotNull(long value) {
|
|
|
+ // 如果值为0L,认为是“空”,返回false
|
|
|
+ return value != 0;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public Result findAll(UserShouyeDto dto) {
|
|
|
+ System.err.println(dto.getUid1());
|
|
|
+// 将所有正在联系的用户展示
|
|
|
+ QueryWrapper<UserShouye> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("uid1", dto.getUid1());
|
|
|
+ queryWrapper.eq("status",0);
|
|
|
+ List<UserShouye> list = this.list(queryWrapper);
|
|
|
+// System.err.println(list);
|
|
|
+// 关联用户 群关联
|
|
|
+// 查出所有的用户信息
|
|
|
+ List<UserLogin> list1 = userLoginService.list();
|
|
|
+ List<Groups> list2 = groupsService.list();
|
|
|
+// 进行关联
|
|
|
+ for (UserShouye u:list) {
|
|
|
+ for (UserLogin l: list1) {
|
|
|
+ if (u.getUid2().equals(l.getId()) && isLongNotNull(u.getUid2())){
|
|
|
+ u.setUserLogin(l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.err.println(list);
|
|
|
+ for (UserShouye u:list) {
|
|
|
+ for (Groups g: list2) {
|
|
|
+ if (u.getGid().equals(g.getGroupId()) && isLongNotNull(u.getGid())){
|
|
|
+ u.setGroupss(g);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.err.println(list);
|
|
|
+ return Result.OK(list, "查询成功");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|