<?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 2022 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：计划应用关联表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-12-06 17:37:23  -->
<mapper namespace="net.northking.cctp.executePlan.db.dao.AtuPlanAppLinkDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                    <!-- 计划主键 -->
    <result column="plan_id" jdbcType="VARCHAR" property="planId"/>
        <!-- 应用主键 -->
    <result column="app_id" jdbcType="VARCHAR" property="appId"/>
        <!-- 应用包名 -->
    <result column="app_package" jdbcType="VARCHAR" property="appPackage"/>
        <!-- 平台类型;0-android,1-ios -->
    <result column="platform_type" jdbcType="CHAR" property="platformType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,plan_id
    ,app_id
    ,app_package
    ,platform_type
  </sql>

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

  <select id="findByPrimaryKey" parameterType="String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </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=VARCHAR}
    </foreach>
  </select>

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

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

  <delete id="deleteByExample" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="id != null">
          id = #{id,jdbcType=VARCHAR}
        </when>
      </choose>
              <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
        </if>
              <if test="planId != null">
          AND plan_id=#{planId,jdbcType=VARCHAR}
        </if>
              <if test="appId != null">
          AND app_id=#{appId,jdbcType=VARCHAR}
        </if>
              <if test="appPackage != null">
          AND app_package=#{appPackage,jdbcType=VARCHAR}
        </if>
              <if test="platformType != null">
          AND platform_type=#{platformType,jdbcType=CHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="planId != null">
        plan_id,
      </if>
      <if test="appId != null">
        app_id,
      </if>
      <if test="appPackage != null">
        app_package,
      </if>
      <if test="platformType != null">
        platform_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="planId != null">
          #{planId, jdbcType=VARCHAR},
      </if>
      <if test="appId != null">
          #{appId, jdbcType=VARCHAR},
      </if>
      <if test="appPackage != null">
          #{appPackage, jdbcType=VARCHAR},
      </if>
      <if test="platformType != null">
          #{platformType, jdbcType=CHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    plan_id,
    app_id,
    app_package,
    platform_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.planId, jdbcType=VARCHAR},
    #{item.appId, jdbcType=VARCHAR},
    #{item.appPackage, jdbcType=VARCHAR},
    #{item.platformType, jdbcType=CHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="planId != null">
        plan_id = #{planId, jdbcType=VARCHAR},
      </if>
      <if test="appId != null">
        app_id = #{appId, jdbcType=VARCHAR},
      </if>
      <if test="appPackage != null">
        app_package = #{appPackage, jdbcType=VARCHAR},
      </if>
      <if test="platformType != null">
        platform_type = #{platformType, jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="planId != null">
        AND plan_id = #{planId,jdbcType=VARCHAR}
      </if>
      <if test="appId != null">
        AND app_id = #{appId,jdbcType=VARCHAR}
      </if>
      <if test="appPackage != null">
        AND app_package = #{appPackage,jdbcType=VARCHAR}
      </if>
      <if test="platformType != null">
        AND platform_type = #{platformType,jdbcType=CHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="planId != null">
        AND plan_id=#{planId,jdbcType=VARCHAR}
      </if>
      <if test="appId != null">
        AND app_id=#{appId,jdbcType=VARCHAR}
      </if>
      <if test="appPackage != null">
        AND app_package=#{appPackage,jdbcType=VARCHAR}
      </if>
      <if test="platformType != null">
        AND platform_type=#{platformType,jdbcType=CHAR}
      </if>
    </trim>
  </select>

</mapper>