Procházet zdrojové kódy

feat:按钮组添加该按钮是否已经绑定标识

xuezizhuo před 1 rokem
rodič
revize
94fac88209

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/entity/DragTableBtn.java

@@ -78,6 +78,9 @@ public class DragTableBtn extends BaseEntity
     /** 更新者ID */
     private Long updateById;
 
+    // 按钮是否被绑定
+    private Boolean whetherBind = false;
+
     /** 子菜单 */
     private List<DragTableBtn> children = new ArrayList<DragTableBtn>();
 
@@ -253,6 +256,13 @@ public class DragTableBtn extends BaseEntity
         this.btnTableFormGroupKey = btnTableFormGroupKey;
     }
 
+    public Boolean getWhetherBind() {
+        return whetherBind;
+    }
+
+    public void setWhetherBind(Boolean whetherBind) {
+        this.whetherBind = whetherBind;
+    }
 
     @Override
     public String toString() {

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/DragTableBtnRelevanceMapper.java

@@ -64,4 +64,18 @@ public interface DragTableBtnRelevanceMapper
      * 根据tableKey查询所有按钮key
      */
     List<String> selectBtnKeyByTableKey(String tableKey);
+
+    /**
+     * 查询按钮是否绑定表格
+     * @param btnKeys
+     * @return
+     */
+    int selectBtnKeyBindOrNot(List<String> btnKeys);
+
+    /**
+     * 根据按钮key查询
+     * @param btnKeys
+     * @return
+     */
+    List<DragTableBtnRelevance> selectDragTableBtnRelevanceByBtnKeys(List<String> btnKeys);
 }

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IDragTableBtnRelevanceService.java

@@ -60,4 +60,18 @@ public interface IDragTableBtnRelevanceService
      * @return 结果
      */
     int deleteDragTableBtnRelevanceByTableKey(String tableKey);
+
+    /**
+     * 查询按钮是否绑定表格
+     * @param btnKeys
+     * @return
+     */
+    int selectBtnKeyBindOrNot(List<String> btnKeys);
+
+    /**
+     * 根据按钮key查询
+     * @param btnKeys
+     * @return
+     */
+    List<DragTableBtnRelevance> selectDragTableBtnRelevanceByBtnKeys(List<String> btnKeys);
 }

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableBtnRelevanceServiceImpl.java

@@ -99,4 +99,14 @@ public class DragTableBtnRelevanceServiceImpl implements IDragTableBtnRelevanceS
     {
         return dragTableBtnRelevanceMapper.deleteDragTableBtnRelevanceByTableKey(tableKey);
     }
+
+    @Override
+    public int selectBtnKeyBindOrNot(List<String> btnKeys) {
+        return dragTableBtnRelevanceMapper.selectBtnKeyBindOrNot(btnKeys);
+    }
+
+    @Override
+    public List<DragTableBtnRelevance> selectDragTableBtnRelevanceByBtnKeys(List<String> btnKeys) {
+        return dragTableBtnRelevanceMapper.selectDragTableBtnRelevanceByBtnKeys(btnKeys);
+    }
 }

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableBtnServiceImpl.java

@@ -9,6 +9,8 @@ import com.ruoyi.common.core.domain.entity.SysMenu;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.entity.DragTableBtn;
+import com.ruoyi.system.entity.DragTableBtnRelevance;
+import com.ruoyi.system.mapper.DragTableBtnRelevanceMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.DragTableBtnMapper;
@@ -27,6 +29,9 @@ public class DragTableBtnServiceImpl implements IDragTableBtnService
     @Autowired
     private DragTableBtnMapper dragTableBtnMapper;
 
+    @Autowired
+    private DragTableBtnRelevanceMapper dragTableBtnRelevanceMapper;
+
     /**
      * 查询格绑定的自定义按钮
      * 
@@ -50,6 +55,14 @@ public class DragTableBtnServiceImpl implements IDragTableBtnService
     {
         // 根据分页得到根节点数据
         List<DragTableBtn> rootNodes = dragTableBtnMapper.selectDragTableBtnList(dragTableBtn);
+        //给已经绑定的按钮添加标识
+        List<DragTableBtnRelevance> dragTableBtnRelevanceList = dragTableBtnRelevanceMapper.selectDragTableBtnRelevanceList(new DragTableBtnRelevance());
+        List<String> btnKeys = dragTableBtnRelevanceList.stream().map(DragTableBtnRelevance::getBtnKey).collect(Collectors.toList());
+        for (DragTableBtn r: rootNodes){
+            if(btnKeys.contains(r.getBtnKey())){
+                r.setWhetherBind(true);
+            }
+        }
         //查询子节点
         List<Long> ids = rootNodes.stream().map(m -> m.getId()).collect(Collectors.toList());
         if (ids.isEmpty()){

+ 16 - 0
ruoyi-system/src/main/resources/mapper/dragmapper/DragTableBtnRelevanceMapper.xml

@@ -57,4 +57,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectBtnKeyByTableKey" resultType="string">
         select btn_key from drag_table_btn_relevance where table_key = #{tableKey}
     </select>
+
+    <select id="selectBtnKeyBindOrNot" resultType="int">
+        select count(1) from drag_table_btn_relevance where btn_key in
+        <foreach collection="list" item="btnKey" open="(" close=")" separator=",">
+            #{btnKey}
+        </foreach>
+    </select>
+
+    <select id="selectDragTableBtnRelevanceByBtnKeys" resultMap="DragTableBtnRelevanceResult">
+        <include refid="selectDragTableBtnRelevanceVo"></include>
+        where btn_key in
+        <foreach collection="list" item="btnKey" open="(" close=")" separator=",">
+            #{btnKey}
+        </foreach>
+    </select>
+
 </mapper>