<?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-24 16:58:38  -->
<mapper namespace="net.northking.cctp.dataPool.db.dao.DataResourcePackageDao">


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

  <resultMap id="DetailMap" type="net.northking.cctp.dataPool.dto.dataRule.DataResourcePackageDetailDto">
      <!-- id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                              <!-- 资源包名称 -->
    <result column="name" jdbcType="VARCHAR" property="name"/>
        <!-- 资源包描述 -->
    <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <!-- 资源包存放地址 -->
    <result column="package_addr" jdbcType="VARCHAR" property="packageAddr"/>
        <!-- 系统id -->
    <result column="pro_id" jdbcType="VARCHAR" property="proId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 创建人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>

  <select id="pagingQuery" resultMap="DetailMap" parameterType="net.northking.cctp.dataPool.db.entity.DataResourcePackage">
    select
    id
    ,name
    ,memo
    ,package_addr
    ,pro_id
    ,tenant_id
    ,created_by
    ,updated_by
    ,created_time
    ,updated_time
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="name != null">
        AND name = #{name,jdbcType=VARCHAR}
      </if>
      <if test="memo != null">
        AND memo = #{memo,jdbcType=VARCHAR}
      </if>
      <if test="packageAddr != null">
        AND package_addr = #{packageAddr,jdbcType=VARCHAR}
      </if>
      <if test="proId != null">
        AND pro_id = #{proId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>
  <select id="getDataResourcePackages" resultMap="DetailMap" parameterType="net.northking.cctp.common.http.QueryByPage">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="query.name != null and query.name != ''">
        AND LOCATE(#{query.name,jdbcType=VARCHAR},name) &gt; 0
      </if>
      <if test="query.proId != null and query.proId != ''">
        AND pro_id = #{query.proId,jdbcType=VARCHAR}
      </if>
      <if test="query.tenantId != null and query.tenantId != ''">
        AND tenant_id = #{query.tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
    order by created_time desc
  </select>
  <select id="queryByIds" parameterType="list" resultType="net.northking.cctp.dataPool.db.entity.DataResourcePackage">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="list != null and list.size > 0">
        AND id IN
        <foreach collection="list" open="(" index="index" item="item" close=")" separator=",">
          #{item,jdbcType=VARCHAR}
        </foreach>
      </if>
    </trim>
  </select>
</mapper>