<?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-08-29 10:24:48  -->
<mapper namespace="net.northking.cctp.platform.db.dao.CpComponentLibraryDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.platform.db.entity.CpComponentLibrary">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                        <!-- 库名 -->
    <result column="library_name" jdbcType="VARCHAR" property="libraryName"/>
        <!-- 库别名 -->
    <result column="library_alias" jdbcType="VARCHAR" property="libraryAlias"/>
        <!-- 库文件名 -->
    <result column="file_name" jdbcType="VARCHAR" property="fileName"/>
        <!-- 库文件地址 -->
    <result column="file_path" jdbcType="VARCHAR" property="filePath"/>
        <!-- 使用状态0-可用1-禁用 -->
    <result column="library_status" jdbcType="INTEGER" property="libraryStatus"/>
        <!--  -->
    <result column="library_intro" jdbcType="VARCHAR" property="libraryIntro"/>
        <!-- 版本更新日志 -->
    <result column="change_log" jdbcType="VARCHAR" property="changeLog"/>
        <!-- 组件库版本号 -->
    <result column="library_version" jdbcType="VARCHAR" property="libraryVersion"/>
        <!-- 组件库类别0-公共，1-接口，2-pcbs，3-pccs，4-安卓，5-ios， -->
    <result column="library_type" jdbcType="INTEGER" property="libraryType"/>
        <!-- 创建人 -->
    <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"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,library_name
    ,library_alias
    ,file_name
    ,file_path
    ,library_status
    ,library_intro
    ,change_log
    ,library_version
    ,library_type
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cp_component_library
  </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" resultMap="BaseResultMap">
    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.platform.db.entity.CpComponentLibrary">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="libraryName != null">
          AND library_name=#{libraryName,jdbcType=VARCHAR}
      </if>
      <if test="libraryAlias != null">
          AND library_alias=#{libraryAlias,jdbcType=VARCHAR}
      </if>
      <if test="fileName != null">
          AND file_name=#{fileName,jdbcType=VARCHAR}
      </if>
      <if test="filePath != null">
          AND file_path=#{filePath,jdbcType=VARCHAR}
      </if>
      <if test="libraryStatus != null">
          AND library_status=#{libraryStatus,jdbcType=INTEGER}
      </if>
      <if test="libraryIntro != null">
          AND library_intro=#{libraryIntro,jdbcType=VARCHAR}
      </if>
      <if test="changeLog != null">
          AND change_log=#{changeLog,jdbcType=VARCHAR}
      </if>
      <if test="libraryVersion != null">
          AND library_version=#{libraryVersion,jdbcType=VARCHAR}
      </if>
      <if test="libraryType != null">
          AND library_type=#{libraryType,jdbcType=INTEGER}
      </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>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.platform.db.entity.CpComponentLibrary">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="libraryName != null">
        library_name,
      </if>
      <if test="libraryAlias != null">
        library_alias,
      </if>
      <if test="fileName != null">
        file_name,
      </if>
      <if test="filePath != null">
        file_path,
      </if>
      <if test="libraryStatus != null">
        library_status,
      </if>
      <if test="libraryIntro != null">
        library_intro,
      </if>
      <if test="changeLog != null">
        change_log,
      </if>
      <if test="libraryVersion != null">
        library_version,
      </if>
      <if test="libraryType != null">
        library_type,
      </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>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="libraryName != null">
          #{libraryName, jdbcType=VARCHAR},
      </if>
      <if test="libraryAlias != null">
          #{libraryAlias, jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
          #{fileName, jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
          #{filePath, jdbcType=VARCHAR},
      </if>
      <if test="libraryStatus != null">
          #{libraryStatus, jdbcType=INTEGER},
      </if>
      <if test="libraryIntro != null">
          #{libraryIntro, jdbcType=VARCHAR},
      </if>
      <if test="changeLog != null">
          #{changeLog, jdbcType=VARCHAR},
      </if>
      <if test="libraryVersion != null">
          #{libraryVersion, jdbcType=VARCHAR},
      </if>
      <if test="libraryType != null">
          #{libraryType, jdbcType=INTEGER},
      </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>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    library_name,
    library_alias,
    file_name,
    file_path,
    library_status,
    library_intro,
    change_log,
    library_version,
    library_type,
    created_by,
    created_time,
    updated_by,
    updated_time,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.libraryName, jdbcType=VARCHAR},
    #{item.libraryAlias, jdbcType=VARCHAR},
    #{item.fileName, jdbcType=VARCHAR},
    #{item.filePath, jdbcType=VARCHAR},
    #{item.libraryStatus, jdbcType=INTEGER},
    #{item.libraryIntro, jdbcType=VARCHAR},
    #{item.changeLog, jdbcType=VARCHAR},
    #{item.libraryVersion, jdbcType=VARCHAR},
    #{item.libraryType, jdbcType=INTEGER},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.platform.db.entity.CpComponentLibrary">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="libraryName != null">
        library_name = #{libraryName, jdbcType=VARCHAR},
      </if>
      <if test="libraryAlias != null">
        library_alias = #{libraryAlias, jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
        file_name = #{fileName, jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
        file_path = #{filePath, jdbcType=VARCHAR},
      </if>
      <if test="libraryStatus != null">
        library_status = #{libraryStatus, jdbcType=INTEGER},
      </if>
      <if test="libraryIntro != null">
        library_intro = #{libraryIntro, jdbcType=VARCHAR},
      </if>
      <if test="changeLog != null">
        change_log = #{changeLog, jdbcType=VARCHAR},
      </if>
      <if test="libraryVersion != null">
        library_version = #{libraryVersion, jdbcType=VARCHAR},
      </if>
      <if test="libraryType != null">
        library_type = #{libraryType, jdbcType=INTEGER},
      </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}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.platform.db.entity.CpComponentLibrary">
    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="libraryName != null">
        AND library_name = #{libraryName,jdbcType=VARCHAR}
      </if>
      <if test="libraryAlias != null">
        AND library_alias = #{libraryAlias,jdbcType=VARCHAR}
      </if>
      <if test="fileName != null">
        AND file_name = #{fileName,jdbcType=VARCHAR}
      </if>
      <if test="filePath != null">
        AND file_path = #{filePath,jdbcType=VARCHAR}
      </if>
      <if test="libraryStatus != null">
        AND library_status = #{libraryStatus,jdbcType=INTEGER}
      </if>
      <if test="libraryIntro != null">
        AND library_intro = #{libraryIntro,jdbcType=VARCHAR}
      </if>
      <if test="changeLog != null">
        AND change_log = #{changeLog,jdbcType=VARCHAR}
      </if>
      <if test="libraryVersion != null">
        AND library_version = #{libraryVersion,jdbcType=VARCHAR}
      </if>
      <if test="libraryType != null">
        AND library_type = #{libraryType,jdbcType=INTEGER}
      </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>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.platform.db.entity.CpComponentLibrary">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="libraryName != null">
        AND library_name=#{libraryName,jdbcType=VARCHAR}
      </if>
      <if test="libraryAlias != null">
        AND library_alias=#{libraryAlias,jdbcType=VARCHAR}
      </if>
      <if test="fileName != null">
        AND file_name=#{fileName,jdbcType=VARCHAR}
      </if>
      <if test="filePath != null">
        AND file_path=#{filePath,jdbcType=VARCHAR}
      </if>
      <if test="libraryStatus != null">
        AND library_status=#{libraryStatus,jdbcType=INTEGER}
      </if>
      <if test="libraryIntro != null">
        AND library_intro=#{libraryIntro,jdbcType=VARCHAR}
      </if>
      <if test="changeLog != null">
        AND change_log=#{changeLog,jdbcType=VARCHAR}
      </if>
      <if test="libraryVersion != null">
        AND library_version=#{libraryVersion,jdbcType=VARCHAR}
      </if>
      <if test="libraryType != null">
        AND library_type=#{libraryType,jdbcType=INTEGER}
      </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>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>