浏览代码

Merge branch 'refs/heads/feature-lihb-20250731' into test-merge

LHB 6 天之前
父节点
当前提交
dbf9f2a5e9

+ 4 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialCyTestType.java

@@ -47,4 +47,8 @@ public class TrialCyTestType {
     @TableField("order_index")
     @ApiModelProperty("顺序号")
     private String orderIndex;
+
+    @TableField(exist = false)
+    @ApiModelProperty("判断是否有子节点")
+    private Boolean hasChildren;
 }

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialCyTestTypeMapper.java

@@ -1,8 +1,11 @@
 package org.springblade.business.mapper;
 
+import org.apache.ibatis.annotations.Param;
 import org.springblade.business.entity.TrialCyTestType;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
 * @author LHB
 * @description 针对表【u_trial_cy_test_type(成渝-试验检测树)】的数据库操作Mapper
@@ -11,6 +14,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 */
 public interface TrialCyTestTypeMapper extends BaseMapper<TrialCyTestType> {
 
+    List<TrialCyTestType> getTree(@Param("projectId") Long projectId,
+                                  @Param("parentId") String parentId);
 }
 
 

+ 18 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialCyTestTypeMapper.xml

@@ -3,4 +3,22 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.business.mapper.TrialCyTestTypeMapper">
+    <sql id="Base_sql">
+        p_key_id,
+        project_id,
+        id,
+        father_id,
+        name,
+        order_index,
+        create_time
+    </sql>
+    <select id="getTree" resultType="org.springblade.business.entity.TrialCyTestType">
+        select
+            <include refid="Base_sql"/>,
+            (select count(1) > 0 from u_trial_cy_test_type where father_id = t.id) has_children
+        from u_trial_cy_test_type t
+        where project_id = #{projectId}
+          and father_id = #{parentId}
+        order by order_index
+    </select>
 </mapper>

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/TrialCyTestTypeService.java

@@ -3,6 +3,8 @@ package org.springblade.business.service;
 import org.springblade.business.entity.TrialCyTestType;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
 * @author LHB
 * @description 针对表【u_trial_cy_test_type(成渝-试验检测树)】的数据库操作Service
@@ -10,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
 */
 public interface TrialCyTestTypeService extends IService<TrialCyTestType> {
 
+    List<TrialCyTestType> getTree(Long projectId, String parentId);
 }

+ 1 - 5
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialCyServiceImpl.java

@@ -51,11 +51,7 @@ public class TrialCyServiceImpl implements TrialCyService {
 
     @Override
     public List<TrialCyTestType> getTree(Long projectId, String parentId) {
-        List<TrialCyTestType> list = trialCyTestTypeService.list(Wrappers.<TrialCyTestType>lambdaQuery()
-                .eq(TrialCyTestType::getProjectId, projectId)
-                .eq(TrialCyTestType::getFatherId, parentId)
-                .orderByAsc(TrialCyTestType::getOrderIndex)
-        );
+        List<TrialCyTestType> list = trialCyTestTypeService.getTree(projectId, parentId);
         return list;
     }
 

+ 7 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialCyTestTypeServiceImpl.java

@@ -6,6 +6,9 @@ import org.springblade.business.service.TrialCyTestTypeService;
 import org.springblade.business.mapper.TrialCyTestTypeMapper;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
+import java.util.List;
+
 /**
 * @author LHB
 * @description 针对表【u_trial_cy_test_type(成渝-试验检测树)】的数据库操作Service实现
@@ -14,7 +17,10 @@ import org.springframework.stereotype.Service;
 @Service
 public class TrialCyTestTypeServiceImpl extends ServiceImpl<TrialCyTestTypeMapper, TrialCyTestType>
     implements TrialCyTestTypeService {
-
+    @Override
+    public List<TrialCyTestType> getTree(Long projectId, String parentId) {
+        return baseMapper.getTree(projectId, parentId);
+    }
 }