From b34d941094d11e21e21a2ceead8a9fdeee640e2d Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 27 五月 2022 11:20:55 +0800
Subject: [PATCH] 列表

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java
index edcea02..51bcf77 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java
@@ -1,15 +1,19 @@
 package com.sandu.ximon.admin.service;
 
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
 import com.sandu.common.execption.BusinessException;
+import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
 import com.sandu.ximon.admin.param.PoleGroupParam;
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.dao.domain.PoleGroup;
+import com.sandu.ximon.dao.domain.PoleGroupRelation;
 import com.sandu.ximon.dao.mapper.PoleGroupMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -25,7 +29,9 @@
 
     public boolean addGroup(PoleGroupParam param) {
         PoleGroup group = new PoleGroup();
-        group.setClientId(SecurityUtils.getClientId());
+        if (SecurityUtils.getClientId() != null) {
+            group.setClientId(SecurityUtils.getUserId());
+        }
         group.setGroupName(param.getGroupName());
         return save(group);
     }
@@ -46,26 +52,40 @@
         if (poleGroup == null) {
             throw new BusinessException("鏈壘鍒拌鍒嗙粍");
         }
+        /**
+         * 鍒櫎
+         */
+        poleGroupRelationService.remove(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId, groupId));
         return removeById(groupId);
     }
 
-    public List<PoleGroup> groupList() {
+    public List<PoleGroup> groupList(BaseConditionVO baseConditionVO, String keyword, Long groupid) {
         Long clientId = SecurityUtils.getClientId();
+        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+
+//        LambdaQueryWrapper<PoleGroup> wrapper = new LambdaQueryWrapper<>();
+        List<PoleGroup> list = new ArrayList<>();
         if (clientId == null) {
-            return list();
+            list = list(Wrappers.lambdaQuery(PoleGroup.class).like(PoleGroup::getGroupName, keyword));
+
         } else {
-            return list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId));
+            list = list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId).like(PoleGroup::getGroupName, keyword));
         }
+        list.forEach(poleGroup -> {
+//            int size = poleGroupRelationService.list(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId, poleGroup.getGroupId())).size();
+            poleGroup.setPoleCount(poleGroupRelationService.list(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId, poleGroup.getGroupId())).size());
+        });
+        return list;
     }
 
     /**
      * 缁戝畾鐏潌
      */
-    public boolean bindPole(Long groupId,List<Long> poleIdList) {
+    public boolean bindPole(Long groupId, List<Long> poleIdList) {
         PoleGroup poleGroup = getById(groupId);
         if (poleGroup == null) {
             throw new BusinessException("鏈壘鍒拌鍒嗙粍");
         }
-        return poleGroupRelationService.saveBinding(groupId,poleIdList);
+        return poleGroupRelationService.saveBinding(groupId, poleIdList);
     }
 }

--
Gitblit v1.9.3