<?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-10-13 10:00:44  -->
<mapper namespace="net.northking.cctp.scriptcase.db.dao.AppDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.scriptcase.db.entity.App">
      <!-- 应用id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                              <!-- 应用名称 -->
    <result column="app_name" jdbcType="VARCHAR" property="appName"/>
        <!-- 应用大小 -->
    <result column="app_size" jdbcType="VARCHAR" property="appSize"/>
        <!-- 包名称 -->
    <result column="package_name" jdbcType="VARCHAR" property="packageName"/>
        <!-- 构建版本 -->
    <result column="build_version" jdbcType="VARCHAR" property="buildVersion"/>
        <!-- 平台类型$$$0-android,1-IOS -->
    <result column="platform" jdbcType="VARCHAR" property="platform"/>
        <!-- 脚本文件地址 -->
    <result column="app_url" jdbcType="VARCHAR" property="appUrl"/>
        <!-- 版本说明 -->
    <result column="version_mark" jdbcType="VARCHAR" property="versionMark"/>
        <!-- 设备归属对象ID -->
    <result column="owner_id" jdbcType="VARCHAR" property="ownerId"/>
        <!-- 租户ID -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- app图标 -->
    <result column="app_icon" jdbcType="BLOB" property="appIcon"/>
        <!-- 备注 -->
    <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <!-- 版本编号 -->
    <result column="version_code" jdbcType="INTEGER" property="versionCode"/>
        <!-- activity -->
    <result column="activity" jdbcType="VARCHAR" property="activity"/>
        <!-- 上传人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,app_name
    ,app_size
    ,package_name
    ,build_version
    ,platform
    ,app_url
    ,version_mark
    ,owner_id
    ,tenant_id
    ,app_icon
    ,remarks
    ,version_code
    ,activity
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.app
  </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.scriptcase.db.entity.App">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="appName != null">
          AND app_name=#{appName,jdbcType=VARCHAR}
      </if>
      <if test="appSize != null">
          AND app_size=#{appSize,jdbcType=VARCHAR}
      </if>
      <if test="packageName != null">
          AND package_name=#{packageName,jdbcType=VARCHAR}
      </if>
      <if test="buildVersion != null">
          AND build_version=#{buildVersion,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
          AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="appUrl != null">
          AND app_url=#{appUrl,jdbcType=VARCHAR}
      </if>
      <if test="versionMark != null">
          AND version_mark=#{versionMark,jdbcType=VARCHAR}
      </if>
      <if test="ownerId != null">
          AND owner_id=#{ownerId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="appIcon != null">
          AND app_icon=#{appIcon,jdbcType=BLOB}
      </if>
      <if test="remarks != null">
          AND remarks=#{remarks,jdbcType=VARCHAR}
      </if>
      <if test="versionCode != null">
          AND version_code=#{versionCode,jdbcType=INTEGER}
      </if>
      <if test="activity != null">
          AND activity=#{activity,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
          AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
          AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.scriptcase.db.entity.App">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="appName != null">
        app_name,
      </if>
      <if test="appSize != null">
        app_size,
      </if>
      <if test="packageName != null">
        package_name,
      </if>
      <if test="buildVersion != null">
        build_version,
      </if>
      <if test="platform != null">
        platform,
      </if>
      <if test="appUrl != null">
        app_url,
      </if>
      <if test="versionMark != null">
        version_mark,
      </if>
      <if test="ownerId != null">
        owner_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="appIcon != null">
        app_icon,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="versionCode != null">
        version_code,
      </if>
      <if test="activity != null">
        activity,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="appName != null">
          #{appName, jdbcType=VARCHAR},
      </if>
      <if test="appSize != null">
          #{appSize, jdbcType=VARCHAR},
      </if>
      <if test="packageName != null">
          #{packageName, jdbcType=VARCHAR},
      </if>
      <if test="buildVersion != null">
          #{buildVersion, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
          #{platform, jdbcType=VARCHAR},
      </if>
      <if test="appUrl != null">
          #{appUrl, jdbcType=VARCHAR},
      </if>
      <if test="versionMark != null">
          #{versionMark, jdbcType=VARCHAR},
      </if>
      <if test="ownerId != null">
          #{ownerId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="appIcon != null">
          #{appIcon, jdbcType=BLOB},
      </if>
      <if test="remarks != null">
          #{remarks, jdbcType=VARCHAR},
      </if>
      <if test="versionCode != null">
          #{versionCode, jdbcType=INTEGER},
      </if>
      <if test="activity != null">
          #{activity, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    app_name,
    app_size,
    package_name,
    build_version,
    platform,
    app_url,
    version_mark,
    owner_id,
    tenant_id,
    app_icon,
    remarks,
    version_code,
    activity,
    created_by,
    created_time,
    updated_by,
    updated_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.appName, jdbcType=VARCHAR},
    #{item.appSize, jdbcType=VARCHAR},
    #{item.packageName, jdbcType=VARCHAR},
    #{item.buildVersion, jdbcType=VARCHAR},
    #{item.platform, jdbcType=VARCHAR},
    #{item.appUrl, jdbcType=VARCHAR},
    #{item.versionMark, jdbcType=VARCHAR},
    #{item.ownerId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.appIcon, jdbcType=BLOB},
    #{item.remarks, jdbcType=VARCHAR},
    #{item.versionCode, jdbcType=INTEGER},
    #{item.activity, jdbcType=VARCHAR},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.scriptcase.db.entity.App">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="appName != null">
        app_name = #{appName, jdbcType=VARCHAR},
      </if>
      <if test="appSize != null">
        app_size = #{appSize, jdbcType=VARCHAR},
      </if>
      <if test="packageName != null">
        package_name = #{packageName, jdbcType=VARCHAR},
      </if>
      <if test="buildVersion != null">
        build_version = #{buildVersion, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
        platform = #{platform, jdbcType=VARCHAR},
      </if>
      <if test="appUrl != null">
        app_url = #{appUrl, jdbcType=VARCHAR},
      </if>
      <if test="versionMark != null">
        version_mark = #{versionMark, jdbcType=VARCHAR},
      </if>
      <if test="ownerId != null">
        owner_id = #{ownerId, jdbcType=VARCHAR},
      </if>
      <if test="appIcon != null">
        app_icon = #{appIcon, jdbcType=BLOB},
      </if>
      <if test="remarks != null">
        remarks = #{remarks, jdbcType=VARCHAR},
      </if>
      <if test="versionCode != null">
        version_code = #{versionCode, jdbcType=INTEGER},
      </if>
      <if test="activity != null">
        activity = #{activity, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.scriptcase.db.entity.App">
    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="appName != null">
        AND app_name = #{appName,jdbcType=VARCHAR}
      </if>
      <if test="appSize != null">
        AND app_size = #{appSize,jdbcType=VARCHAR}
      </if>
      <if test="packageName != null">
        AND package_name = #{packageName,jdbcType=VARCHAR}
      </if>
      <if test="buildVersion != null">
        AND build_version = #{buildVersion,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform = #{platform,jdbcType=VARCHAR}
      </if>
      <if test="appUrl != null">
        AND app_url = #{appUrl,jdbcType=VARCHAR}
      </if>
      <if test="versionMark != null">
        AND version_mark = #{versionMark,jdbcType=VARCHAR}
      </if>
      <if test="ownerId != null">
        AND owner_id = #{ownerId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="appIcon != null">
        AND app_icon = #{appIcon,jdbcType=BLOB}
      </if>
      <if test="remarks != null">
        AND remarks = #{remarks,jdbcType=VARCHAR}
      </if>
      <if test="versionCode != null">
        AND version_code = #{versionCode,jdbcType=INTEGER}
      </if>
      <if test="activity != null">
        AND activity = #{activity,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.scriptcase.db.entity.App">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="appName != null">
        AND app_name=#{appName,jdbcType=VARCHAR}
      </if>
      <if test="appSize != null">
        AND app_size=#{appSize,jdbcType=VARCHAR}
      </if>
      <if test="packageName != null">
        AND package_name=#{packageName,jdbcType=VARCHAR}
      </if>
      <if test="buildVersion != null">
        AND build_version=#{buildVersion,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="appUrl != null">
        AND app_url=#{appUrl,jdbcType=VARCHAR}
      </if>
      <if test="versionMark != null">
        AND version_mark=#{versionMark,jdbcType=VARCHAR}
      </if>
      <if test="ownerId != null">
        AND owner_id=#{ownerId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="appIcon != null">
        AND app_icon=#{appIcon,jdbcType=BLOB}
      </if>
      <if test="remarks != null">
        AND remarks=#{remarks,jdbcType=VARCHAR}
      </if>
      <if test="versionCode != null">
        AND version_code=#{versionCode,jdbcType=INTEGER}
      </if>
      <if test="activity != null">
        AND activity=#{activity,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

</mapper>