Selaa lähdekoodia

更新文件 SmartAuthorGroupServiceImpl.java

陈士柏 2 vuotta sitten
vanhempi
commit
99e8606465

+ 54 - 2
src/main/java/com/template/services/impl/SmartAuthorGroupServiceImpl.java

@@ -1,21 +1,27 @@
 package com.template.services.impl;
 package com.template.services.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.template.mapper.SmartAuthorGroupMapper;
-import com.template.mapper.SmartAuthorityMapper;
+import com.template.mapper.*;
+import com.template.model.pojo.SmartApply;
 import com.template.model.pojo.SmartAuthorGroup;
 import com.template.model.pojo.SmartAuthorGroup;
 import com.template.model.pojo.SmartAuthorGroup;
 import com.template.model.pojo.SmartAuthorGroup;
 import com.template.mapper.SmartAuthorGroupMapper;
 import com.template.mapper.SmartAuthorGroupMapper;
+import com.template.model.pojo.SmartUser;
 import com.template.model.result.PageUtils;
 import com.template.model.result.PageUtils;
+import com.template.model.weixin.AuthorListGroup;
 import com.template.services.SmartAuthorGroupService;
 import com.template.services.SmartAuthorGroupService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -29,6 +35,10 @@ import java.util.List;
 public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMapper, SmartAuthorGroup> implements SmartAuthorGroupService {
 public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMapper, SmartAuthorGroup> implements SmartAuthorGroupService {
     @Autowired
     @Autowired
     private SmartAuthorGroupMapper smartAuthorGroupMapper;
     private SmartAuthorGroupMapper smartAuthorGroupMapper;
+    @Autowired
+    public SmartUserMapper smartUserMapper;
+    @Autowired
+    public SmartApplyMapper smartApplyMapper;
 
 
     @Override
     @Override
     public int insertSmartAuthorGroup(SmartAuthorGroup sa) {
     public int insertSmartAuthorGroup(SmartAuthorGroup sa) {
@@ -83,4 +93,46 @@ public class SmartAuthorGroupServiceImpl extends ServiceImpl<SmartAuthorGroupMap
         List<SmartAuthorGroup> result = smartAuthorGroupMapper.smartAuthorGroup(userId);
         List<SmartAuthorGroup> result = smartAuthorGroupMapper.smartAuthorGroup(userId);
         return result;
         return result;
     }
     }
+
+    @Override
+    public List<AuthorListGroup> queryCommentTreeRecords(Integer pid, List<SmartAuthorGroup> lists) {
+        List<AuthorListGroup> newTrees = new ArrayList<>();
+        List<SmartAuthorGroup> datas = lists.stream().filter(e -> e.getParentId().equals(pid)).collect(Collectors.toList());
+        for (SmartAuthorGroup data : datas) {
+            QueryWrapper<SmartUser> queryWrapper1 = new QueryWrapper<>();
+            queryWrapper1.eq("deleted", 0);
+            List<String> userIds = Arrays.asList(data.getUserId().split(","));
+            queryWrapper1.in("id", userIds);
+            List<SmartUser> list1 = smartUserMapper.selectList(queryWrapper1);
+            JSONObject jsonObject1 = new JSONObject();
+            jsonObject1.put("data", list1);
+            QueryWrapper<SmartApply> queryWrapper2 = new QueryWrapper<>();
+            queryWrapper2.eq("deleted", 0);
+            List<String> applyIds = Arrays.asList(data.getApplyId().split(","));
+            queryWrapper2.in("id", applyIds);
+            List<SmartApply> list2 = smartApplyMapper.selectList(queryWrapper2);
+            JSONObject jsonObject2 = new JSONObject();
+            jsonObject2.put("data", list2);
+            AuthorListGroup item = AuthorListGroup.builder()
+                    .id(data.getId())
+                    .parentId(data.getParentId())
+                    .name(data.getName())
+                    .userId(jsonObject1.toJSONString())
+                    .applyId(jsonObject2.toJSONString())
+                    .updateTime(data.getUpdateTime())
+                    .createUser(data.getCreateUser())
+                    .updateUser(data.getUpdateUser())
+                    .deleted(data.getDeleted())
+                    .build();
+            List<AuthorListGroup> news = queryCommentTreeRecords(item.getId(), lists);
+            if (news == null || news.size() == 0) {
+                newTrees.add(item);
+                continue;
+            } else {
+                item.setAuthorListGroups(news);
+                newTrees.add(item);
+            }
+        }
+        return newTrees;
+    }
 }
 }