<?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">
<mapper namespace="io.dataease.base.mapper.DatasetTableUnionMapper">
  <resultMap id="BaseResultMap" type="io.dataease.base.domain.DatasetTableUnion">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="source_table_id" jdbcType="VARCHAR" property="sourceTableId" />
    <result column="source_table_field_id" jdbcType="VARCHAR" property="sourceTableFieldId" />
    <result column="source_union_relation" jdbcType="VARCHAR" property="sourceUnionRelation" />
    <result column="target_table_id" jdbcType="VARCHAR" property="targetTableId" />
    <result column="target_table_field_id" jdbcType="VARCHAR" property="targetTableFieldId" />
    <result column="target_union_relation" jdbcType="VARCHAR" property="targetUnionRelation" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="BIGINT" property="createTime" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, source_table_id, source_table_field_id, source_union_relation, target_table_id, 
    target_table_field_id, target_union_relation, create_by, create_time
  </sql>
  <select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableUnionExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from dataset_table_union
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from dataset_table_union
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from dataset_table_union
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="io.dataease.base.domain.DatasetTableUnionExample">
    delete from dataset_table_union
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="io.dataease.base.domain.DatasetTableUnion">
    insert into dataset_table_union (id, source_table_id, source_table_field_id, 
      source_union_relation, target_table_id, target_table_field_id, 
      target_union_relation, create_by, create_time
      )
    values (#{id,jdbcType=VARCHAR}, #{sourceTableId,jdbcType=VARCHAR}, #{sourceTableFieldId,jdbcType=VARCHAR}, 
      #{sourceUnionRelation,jdbcType=VARCHAR}, #{targetTableId,jdbcType=VARCHAR}, #{targetTableFieldId,jdbcType=VARCHAR}, 
      #{targetUnionRelation,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTableUnion">
    insert into dataset_table_union
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="sourceTableId != null">
        source_table_id,
      </if>
      <if test="sourceTableFieldId != null">
        source_table_field_id,
      </if>
      <if test="sourceUnionRelation != null">
        source_union_relation,
      </if>
      <if test="targetTableId != null">
        target_table_id,
      </if>
      <if test="targetTableFieldId != null">
        target_table_field_id,
      </if>
      <if test="targetUnionRelation != null">
        target_union_relation,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="sourceTableId != null">
        #{sourceTableId,jdbcType=VARCHAR},
      </if>
      <if test="sourceTableFieldId != null">
        #{sourceTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="sourceUnionRelation != null">
        #{sourceUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="targetTableId != null">
        #{targetTableId,jdbcType=VARCHAR},
      </if>
      <if test="targetTableFieldId != null">
        #{targetTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="targetUnionRelation != null">
        #{targetUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableUnionExample" resultType="java.lang.Long">
    select count(*) from dataset_table_union
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update dataset_table_union
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.sourceTableId != null">
        source_table_id = #{record.sourceTableId,jdbcType=VARCHAR},
      </if>
      <if test="record.sourceTableFieldId != null">
        source_table_field_id = #{record.sourceTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="record.sourceUnionRelation != null">
        source_union_relation = #{record.sourceUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="record.targetTableId != null">
        target_table_id = #{record.targetTableId,jdbcType=VARCHAR},
      </if>
      <if test="record.targetTableFieldId != null">
        target_table_field_id = #{record.targetTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="record.targetUnionRelation != null">
        target_union_relation = #{record.targetUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update dataset_table_union
    set id = #{record.id,jdbcType=VARCHAR},
      source_table_id = #{record.sourceTableId,jdbcType=VARCHAR},
      source_table_field_id = #{record.sourceTableFieldId,jdbcType=VARCHAR},
      source_union_relation = #{record.sourceUnionRelation,jdbcType=VARCHAR},
      target_table_id = #{record.targetTableId,jdbcType=VARCHAR},
      target_table_field_id = #{record.targetTableFieldId,jdbcType=VARCHAR},
      target_union_relation = #{record.targetUnionRelation,jdbcType=VARCHAR},
      create_by = #{record.createBy,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.DatasetTableUnion">
    update dataset_table_union
    <set>
      <if test="sourceTableId != null">
        source_table_id = #{sourceTableId,jdbcType=VARCHAR},
      </if>
      <if test="sourceTableFieldId != null">
        source_table_field_id = #{sourceTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="sourceUnionRelation != null">
        source_union_relation = #{sourceUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="targetTableId != null">
        target_table_id = #{targetTableId,jdbcType=VARCHAR},
      </if>
      <if test="targetTableFieldId != null">
        target_table_field_id = #{targetTableFieldId,jdbcType=VARCHAR},
      </if>
      <if test="targetUnionRelation != null">
        target_union_relation = #{targetUnionRelation,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.DatasetTableUnion">
    update dataset_table_union
    set source_table_id = #{sourceTableId,jdbcType=VARCHAR},
      source_table_field_id = #{sourceTableFieldId,jdbcType=VARCHAR},
      source_union_relation = #{sourceUnionRelation,jdbcType=VARCHAR},
      target_table_id = #{targetTableId,jdbcType=VARCHAR},
      target_table_field_id = #{targetTableFieldId,jdbcType=VARCHAR},
      target_union_relation = #{targetUnionRelation,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=BIGINT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
</mapper>