<?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">


  <!-- 请在本文件内添加自定义SQL语句 -->

  <resultMap id="DetailMap" type="net.northking.cctp.executePlan.dto.planLink.AtuPlanAppLinkDetailDto">
      <!-- 主键 -->
    <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>

  <select id="pagingQuery" resultMap="DetailMap" parameterType="net.northking.cctp.executePlan.db.entity.AtuPlanAppLink">
    select
    id
    ,plan_id
    ,app_id
    ,app_package
    ,platform_type
    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="queryAppId" resultType="java.lang.String">
    select app_id from <include refid="Table_Name"/>
    where plan_id = #{planId} and platform_type = #{platformType}
    limit 1
  </select>

  <delete id="deleteAppByPlanId" parameterType="string">
    delete
    from
    <include refid="Table_Name"/>
    where plan_id = #{planId}
  </delete>
</mapper>