<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2023 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：计划脚本关联副表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2023-09-04 09:44:18  -->
<mapper namespace="net.northking.cctp.executePlan.db.dao.AtuPlanScriptLinkMdDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
      <!-- 主键 -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                    <!-- 编辑人id -->
    <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <!-- 计划id -->
    <result column="plan_id" jdbcType="VARCHAR" property="planId"/>
        <!-- 脚本id -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
        <!-- 脚本类型;0-接口，1-pcbs，2-pccs，3-安卓，4-ios -->
    <result column="script_type" jdbcType="VARCHAR" property="scriptType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,user_id
    ,plan_id
    ,script_id
    ,script_type
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.atu_plan_script_link_md
  </sql>

  <select id="findByPrimaryKey" parameterType="Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </select>

  <select id="findByPrimaryKeys" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=BIGINT}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="Long">
    delete from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </delete>

  <delete id="deleteByPrimaryKeys" parameterType="Long">
    delete from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=BIGINT}
    </foreach>
  </delete>

  <delete id="deleteByExample" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="id != null">
          id = #{id,jdbcType=BIGINT}
        </when>
      </choose>
              <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
        </if>
              <if test="userId != null">
          AND user_id=#{userId,jdbcType=VARCHAR}
        </if>
              <if test="planId != null">
          AND plan_id=#{planId,jdbcType=VARCHAR}
        </if>
              <if test="scriptId != null">
          AND script_id=#{scriptId,jdbcType=VARCHAR}
        </if>
              <if test="scriptType != null">
          AND script_type=#{scriptType,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="planId != null">
        plan_id,
      </if>
      <if test="scriptId != null">
        script_id,
      </if>
      <if test="scriptType != null">
        script_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="userId != null">
          #{userId, jdbcType=VARCHAR},
      </if>
      <if test="planId != null">
          #{planId, jdbcType=VARCHAR},
      </if>
      <if test="scriptId != null">
          #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
          #{scriptType, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    user_id,
    plan_id,
    script_id,
    script_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.userId, jdbcType=VARCHAR},
    #{item.planId, jdbcType=VARCHAR},
    #{item.scriptId, jdbcType=VARCHAR},
    #{item.scriptType, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="userId != null">
        user_id = #{userId, jdbcType=VARCHAR},
      </if>
      <if test="planId != null">
        plan_id = #{planId, jdbcType=VARCHAR},
      </if>
      <if test="scriptId != null">
        script_id = #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
        script_type = #{scriptType, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=BIGINT}
      </if>
      <if test="userId != null">
        AND user_id = #{userId,jdbcType=VARCHAR}
      </if>
      <if test="planId != null">
        AND plan_id = #{planId,jdbcType=VARCHAR}
      </if>
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type = #{scriptType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanScriptLinkMd">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="userId != null">
        AND user_id=#{userId,jdbcType=VARCHAR}
      </if>
      <if test="planId != null">
        AND plan_id=#{planId,jdbcType=VARCHAR}
      </if>
      <if test="scriptId != null">
        AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type=#{scriptType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>