<?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="com.ruoyi.zongzhi.mapper.TcDataSourceTjMapper">

    <resultMap type="TcDataSourceTj" id="TcDataSourceTjResult">
        <result property="id" column="id"/>
        <result property="areaId" column="area_id"/>
        <result property="lable1" column="lable1"/>
        <result property="lable2" column="lable2"/>
        <result property="createId" column="create_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateId" column="update_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="isStatus"    column="is_status"    />
        <result property="lable1Sume"    column="lable1Sume"    />
        <result property="lable2Sume"    column="lable2Sume"    />
    </resultMap>

    <sql id="selectTcDataSourceTjVo">
        select id,
               area_id,
               lable1,
               lable2,
               create_id,
               create_by,
               create_time,
               update_id,
               update_by,
               update_time,
               remark,
               is_status,
               lable1Sume,
               lable2Sume
        from tc_data_source_tj
    </sql>

    <select id="selectTcDataSourceTjList" parameterType="TcDataSourceTj" resultMap="TcDataSourceTjResult">
        <include refid="selectTcDataSourceTjVo"/>
        <where>
            <if test="areaId != null ">and area_id = #{areaId}</if>
            <if test="lable1 != null  and lable1 != ''">and lable1 = #{lable1}</if>
            <if test="lable2 != null  and lable2 != ''">and lable2 = #{lable2}</if>
            <if test="createId != null ">and create_id = #{createId}</if>
            <if test="updateId != null ">and update_id = #{updateId}</if>
            <if test="isStatus != null "> and is_status = #{isStatus}</if>
        </where>
    </select>

    <select id="selectTcDataSourceTjById" parameterType="Long" resultMap="TcDataSourceTjResult">
        <include refid="selectTcDataSourceTjVo"/>
        where id = #{id}
    </select>

    <insert id="insertTcDataSourceTj" parameterType="TcDataSourceTj" useGeneratedKeys="true" keyProperty="id">
        insert into tc_data_source_tj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="lable1 != null">lable1,</if>
            <if test="lable2 != null">lable2,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="isStatus != null">is_status,</if>
            <if test="lable1Sume != null">lable1Sume,</if>
            <if test="lable2Sume != null">lable2Sume,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="lable1 != null">#{lable1},</if>
            <if test="lable2 != null">#{lable2},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isStatus != null">#{isStatus},</if>
            <if test="lable1Sume != null">#{lable1Sume},</if>
            <if test="lable2Sume != null">#{lable2Sume},</if>
        </trim>
    </insert>

    <update id="updateTcDataSourceTj" parameterType="TcDataSourceTj">
        update tc_data_source_tj
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="lable1 != null">lable1 = #{lable1},</if>
            <if test="lable2 != null">lable2 = #{lable2},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isStatus != null">is_status=#{isStatus},</if>
            <if test="lable1Sume != null">lable1Sume=#{lable1Sume},</if>
            <if test="lable2Sume != null">lable2Sume=#{lable2Sume},</if>

        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcDataSourceTjById" parameterType="Long">
        delete
        from tc_data_source_tj
        where id = #{id}
    </delete>

    <delete id="deleteTcDataSourceTjByIds" parameterType="String">
        delete from tc_data_source_tj where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>