瀏覽代碼

试验-规范信息-分页接口调整,新增的子数据赋值规范文件id

LHB 3 月之前
父節點
當前提交
985fc7ee5d

+ 21 - 44
blade-service/blade-business/src/main/java/org/springblade/business/mapper/StandardInfoMapper.xml

@@ -26,17 +26,7 @@
         <result property="createUser" column="create_user"/>
         <result property="updateTime" column="update_time"/>
         <result property="updateUser" column="update_user"/>
-        <collection property="info" ofType="org.springblade.business.entity.UStandardInfo">
-            <id property="id" column="info_id"/>
-            <result property="name" column="info_name"/>
-            <result property="parentId" column="info_parent_id"/>
-            <result property="standardId" column="info_standard_id"/>
-            <result property="type" column="info_type"/>
-            <result property="isDeleted" column="info_is_deleted"/>
-            <result property="createTime" column="info_create_time"/>
-            <result property="createUser" column="info_create_user"/>
-            <result property="updateTime" column="info_update_time"/>
-            <result property="updateUser" column="info_update_user"/>
+        <collection property="info" ofType="org.springblade.business.entity.UStandardInfo" select="findByParentId" column="{parentId=id}">
         </collection>
     </resultMap>
 
@@ -45,58 +35,45 @@
         ,name,parent_id,standard_id,type,is_deleted,create_time,
         create_user,update_time,update_user
     </sql>
-    <sql id="Base_Column_List_Page">
-        a.id,
-        a.name,
-        a.parent_id,
-        a.standard_id,
-        a.type,
-        a.is_deleted,
-        a.create_time,
-        a.create_user,
-        a.update_time,
-        a.update_user,
-        b.id AS info_id,
-        b.name AS info_name,
-        b.parent_id AS info_parent_id,
-        b.standard_id AS info_standard_id,
-        b.type AS info_type,
-        b.is_deleted AS info_is_deleted,
-        b.create_time AS info_create_time,
-        b.create_user AS info_create_user,
-        b.update_time AS info_update_time,
-        b.update_user AS info_update_user
-    </sql>
     <select id="selectMyPage" resultMap="BaseResultPageMap">
         SELECT
-            <include refid="Base_Column_List_Page"/>
+            <include refid="Base_Column_List"/>
         FROM
-            u_standard_info a
-            LEFT JOIN u_standard_info b ON a.id = b.parent_id and a.is_deleted = b.is_deleted
+            u_standard_info
         <where>
+            is_deleted = 0
             <if test="query.type != null">
-                AND a.type = #{query.type}
+                AND type = #{query.type}
             </if>
             <choose>
                 <when test="query.parentId != null">
-                    AND a.parent_id = #{query.parentId}
+                    AND parent_id = #{query.parentId}
                 </when>
                 <otherwise>
-                    AND a.parent_id = 0
+                    AND parent_id = 0
                 </otherwise>
             </choose>
             <if test="query.standardId != null">
-                AND a.standard_id =  #{query.standardId}
+                AND standard_id =  #{query.standardId}
             </if>
         </where>
     </select>
     <select id="selectMyOne" resultMap="BaseResultPageMap">
         SELECT
-            <include refid="Base_Column_List_Page"/>
+            <include refid="Base_Column_List"/>
+        FROM
+            u_standard_info
+        WHERE
+            is_deleted = 0 AND
+            id = #{id}
+    </select>
+    <select id="findByParentId" resultType="org.springblade.business.entity.UStandardInfo">
+        select
+            <include refid="Base_Column_List"/>
         FROM
-            u_standard_info a
-            LEFT JOIN u_standard_info b ON a.id = b.parent_id and a.is_deleted = b.is_deleted
+            u_standard_info
         WHERE
-            a.id = #{id}
+            is_deleted = 0
+            AND parent_id = #{parentId}
     </select>
 </mapper>

+ 2 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/UStandardInfoServiceImpl.java

@@ -71,6 +71,7 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, US
             info.forEach(item -> {
                 item.setId(SnowFlakeUtil.getId());
                 item.setParentId(uStandardInfo.getId());
+                item.setStandardId(uStandardInfo.getStandardId());
                 item.setCreateUser(user.getUserId());
             });
 
@@ -101,8 +102,8 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, US
                     //新增的子集合设置id、父级id、创建人
                     item.setId(SnowFlakeUtil.getId());
                     item.setParentId(uStandardInfo.getId());
+                    item.setStandardId(uStandardInfo.getStandardId());
                     item.setCreateUser(user.getUserId());
-
                 } else {
                     //更新的子集合 添加更新人
                     item.setUpdateUser(user.getUserId());