<?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-11-02 11:07:21  -->
<mapper namespace="net.northking.cctp.platform.db.dao.CpComponentListDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.platform.db.entity.CpComponentList">
      <!-- 主键 -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                      <!-- 所属组件库 -->
    <result column="library_id" jdbcType="VARCHAR" property="libraryId"/>
        <!-- 组件名 -->
    <result column="com_name" jdbcType="VARCHAR" property="comName"/>
        <!-- 组件别名 -->
    <result column="com_alias" jdbcType="VARCHAR" property="comAlias"/>
        <!-- 使用类别：0-基础，1-插件2-函数 -->
    <result column="com_category" jdbcType="VARCHAR" property="comCategory"/>
        <!-- 属性:0-公共,-接口,2-pcBS,3-pcCS,4-安卓,5-ios -->
    <result column="com_attributes" jdbcType="VARCHAR" property="comAttributes"/>
        <!-- 组建介绍 -->
    <result column="com_intro" jdbcType="VARCHAR" property="comIntro"/>
        <!-- 是否推荐使用0-推荐，1-不推荐 -->
    <result column="is_deprecated" jdbcType="INTEGER" property="isDeprecated"/>
        <!-- 是否常用0-否1-是 -->
    <result column="is_commonly_use" jdbcType="INTEGER" property="isCommonlyUse"/>
        <!-- 创建人 -->
    <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_id
    ,com_name
    ,com_alias
    ,com_category
    ,com_attributes
    ,com_intro
    ,is_deprecated
    ,is_commonly_use
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cp_component_list
  </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.CpComponentList">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="libraryId != null">
          AND library_id=#{libraryId,jdbcType=VARCHAR}
      </if>
      <if test="comName != null">
          AND com_name=#{comName,jdbcType=VARCHAR}
      </if>
      <if test="comAlias != null">
          AND com_alias=#{comAlias,jdbcType=VARCHAR}
      </if>
      <if test="comCategory != null">
          AND com_category=#{comCategory,jdbcType=VARCHAR}
      </if>
      <if test="comAttributes != null">
          AND com_attributes=#{comAttributes,jdbcType=VARCHAR}
      </if>
      <if test="comIntro != null">
          AND com_intro=#{comIntro,jdbcType=VARCHAR}
      </if>
      <if test="isDeprecated != null">
          AND is_deprecated=#{isDeprecated,jdbcType=INTEGER}
      </if>
      <if test="isCommonlyUse != null">
          AND is_commonly_use=#{isCommonlyUse,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>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.platform.db.entity.CpComponentList">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="libraryId != null">
        library_id,
      </if>
      <if test="comName != null">
        com_name,
      </if>
      <if test="comAlias != null">
        com_alias,
      </if>
      <if test="comCategory != null">
        com_category,
      </if>
      <if test="comAttributes != null">
        com_attributes,
      </if>
      <if test="comIntro != null">
        com_intro,
      </if>
      <if test="isDeprecated != null">
        is_deprecated,
      </if>
      <if test="isCommonlyUse != null">
        is_commonly_use,
      </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="libraryId != null">
          #{libraryId, jdbcType=VARCHAR},
      </if>
      <if test="comName != null">
          #{comName, jdbcType=VARCHAR},
      </if>
      <if test="comAlias != null">
          #{comAlias, jdbcType=VARCHAR},
      </if>
      <if test="comCategory != null">
          #{comCategory, jdbcType=VARCHAR},
      </if>
      <if test="comAttributes != null">
          #{comAttributes, jdbcType=VARCHAR},
      </if>
      <if test="comIntro != null">
          #{comIntro, jdbcType=VARCHAR},
      </if>
      <if test="isDeprecated != null">
          #{isDeprecated, jdbcType=INTEGER},
      </if>
      <if test="isCommonlyUse != null">
          #{isCommonlyUse, 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_id,
    com_name,
    com_alias,
    com_category,
    com_attributes,
    com_intro,
    is_deprecated,
    is_commonly_use,
    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.libraryId, jdbcType=VARCHAR},
    #{item.comName, jdbcType=VARCHAR},
    #{item.comAlias, jdbcType=VARCHAR},
    #{item.comCategory, jdbcType=VARCHAR},
    #{item.comAttributes, jdbcType=VARCHAR},
    #{item.comIntro, jdbcType=VARCHAR},
    #{item.isDeprecated, jdbcType=INTEGER},
    #{item.isCommonlyUse, 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.CpComponentList">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="libraryId != null">
        library_id = #{libraryId, jdbcType=VARCHAR},
      </if>
      <if test="comName != null">
        com_name = #{comName, jdbcType=VARCHAR},
      </if>
      <if test="comAlias != null">
        com_alias = #{comAlias, jdbcType=VARCHAR},
      </if>
      <if test="comCategory != null">
        com_category = #{comCategory, jdbcType=VARCHAR},
      </if>
      <if test="comAttributes != null">
        com_attributes = #{comAttributes, jdbcType=VARCHAR},
      </if>
      <if test="comIntro != null">
        com_intro = #{comIntro, jdbcType=VARCHAR},
      </if>
      <if test="isDeprecated != null">
        is_deprecated = #{isDeprecated, jdbcType=INTEGER},
      </if>
      <if test="isCommonlyUse != null">
        is_commonly_use = #{isCommonlyUse, 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}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.platform.db.entity.CpComponentList">
    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="libraryId != null">
        AND library_id = #{libraryId,jdbcType=VARCHAR}
      </if>
      <if test="comName != null">
        AND com_name = #{comName,jdbcType=VARCHAR}
      </if>
      <if test="comAlias != null">
        AND com_alias = #{comAlias,jdbcType=VARCHAR}
      </if>
      <if test="comCategory != null">
        AND com_category = #{comCategory,jdbcType=VARCHAR}
      </if>
      <if test="comAttributes != null">
        AND com_attributes = #{comAttributes,jdbcType=VARCHAR}
      </if>
      <if test="comIntro != null">
        AND com_intro = #{comIntro,jdbcType=VARCHAR}
      </if>
      <if test="isDeprecated != null">
        AND is_deprecated = #{isDeprecated,jdbcType=INTEGER}
      </if>
      <if test="isCommonlyUse != null">
        AND is_commonly_use = #{isCommonlyUse,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.CpComponentList">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="libraryId != null">
        AND library_id=#{libraryId,jdbcType=VARCHAR}
      </if>
      <if test="comName != null">
        AND com_name=#{comName,jdbcType=VARCHAR}
      </if>
      <if test="comAlias != null">
        AND com_alias=#{comAlias,jdbcType=VARCHAR}
      </if>
      <if test="comCategory != null">
        AND com_category=#{comCategory,jdbcType=VARCHAR}
      </if>
      <if test="comAttributes != null">
        AND com_attributes=#{comAttributes,jdbcType=VARCHAR}
      </if>
      <if test="comIntro != null">
        AND com_intro=#{comIntro,jdbcType=VARCHAR}
      </if>
      <if test="isDeprecated != null">
        AND is_deprecated=#{isDeprecated,jdbcType=INTEGER}
      </if>
      <if test="isCommonlyUse != null">
        AND is_commonly_use=#{isCommonlyUse,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>