<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zcxk.rmcp.core.dao.InstallPlanDataMapper">
  <resultMap id="BaseResultMap" type="com.zcxk.rmcp.core.entity.InstallPlanData">
    <!--@mbg.generated-->
    <!--@Table rmcp_install_plan_data-->
    <id column="id" property="id" />
    <result column="parent_id" property="parentId" />
    <result column="install_plan_id" property="installPlanId" />
    <result column="type" property="type" />
    <result column="name" property="name" />
    <result column="status" property="status" />
    <result column="create_by" property="createBy" />
    <result column="create_date" property="createDate" />
    <result column="update_by" property="updateBy" />
    <result column="update_date" property="updateDate" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, parent_id, install_plan_id, `type`, `name`, `status`, create_by, create_date, 
    update_by, update_date
  </sql>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zcxk.rmcp.core.entity.InstallPlanData" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into rmcp_install_plan_data
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="installPlanId != null">
        install_plan_id,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createDate != null">
        create_date,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateDate != null">
        update_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="parentId != null">
        #{parentId},
      </if>
      <if test="installPlanId != null">
        #{installPlanId},
      </if>
      <if test="type != null">
        #{type},
      </if>
      <if test="name != null">
        #{name},
      </if>
      <if test="status != null">
        #{status},
      </if>
      <if test="createBy != null">
        #{createBy},
      </if>
      <if test="createDate != null">
        #{createDate},
      </if>
      <if test="updateBy != null">
        #{updateBy},
      </if>
      <if test="updateDate != null">
        #{updateDate},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.rmcp.core.entity.InstallPlanData">
    <!--@mbg.generated-->
    update rmcp_install_plan_data
    <set>
      <if test="parentId != null">
        parent_id = #{parentId},
      </if>
      <if test="installPlanId != null">
        install_plan_id = #{installPlanId},
      </if>
      <if test="type != null">
        `type` = #{type},
      </if>
      <if test="name != null">
        `name` = #{name},
      </if>
      <if test="status != null">
        `status` = #{status},
      </if>
      <if test="createBy != null">
        create_by = #{createBy},
      </if>
      <if test="createDate != null">
        create_date = #{createDate},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy},
      </if>
      <if test="updateDate != null">
        update_date = #{updateDate},
      </if>
    </set>
    where id = #{id}
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into rmcp_install_plan_data
    (id, parent_id, install_plan_id, `type`, `name`, `status`, create_by, create_date, update_by,
    update_date)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.id}, #{item.parentId}, #{item.installPlanId}, #{item.type}, #{item.name}, #{item.status},
      #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate})
    </foreach>
  </insert>

  <select id="fondByPlanId" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from rmcp_install_plan_data where status = 1 and install_plan_id = #{planId}
  </select>
</mapper>