<?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.tcZz.mapper.TcYqzsMapper">
    
    <resultMap type="TcYqzs" id="TcYqzsResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="dateTime"    column="date_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="count1"    column="count1"    />
        <result property="count2"    column="count2"    />
    </resultMap>

    <sql id="selectTcYqzsVo">
        select id, area_id, date_time, create_by, create_time, update_by, update_time, remark, count1, count2 from tc_yqzs
    </sql>

    <select id="selectTcYqzsList" parameterType="TcYqzs" resultMap="TcYqzsResult">
        <include refid="selectTcYqzsVo"/>
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="areaId != null ">and area_id = #{areaId}</if>
            <if test="params.beginDateTime != null and params.beginDateTime != '' and params.endDateTime != null and params.endDateTime != ''">
                and date_time between #{params.beginDateTime} and #{params.endDateTime}
            </if>
            <if test="createBy != null  and createBy != ''">and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
                and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
            </if>
            <if test="updateBy != null  and updateBy != ''">and update_by = #{updateBy}</if>
            <if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''">
                and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}
            </if>
            <if test="beginDateTime != null  and endDateTime != null "> and date_time between #{beginDateTime} and #{endDateTime}</if>
            <if test="beginDateTime != null">and date_time &gt;= #{beginDateTime}</if>
            <if test="endDateTime != null">and date_time &lt;= #{endDateTime}</if>
            <if test="remark != null  and remark != ''">and remark = #{remark}</if>
            <if test="count1 != null ">and count1 = #{count1}</if>
            <if test="count2 != null ">and count2 = #{count2}</if>
        </where>
        order by date_time asc
    </select>
    
    <select id="selectTcYqzsById" parameterType="Long" resultMap="TcYqzsResult">
        <include refid="selectTcYqzsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcYqzs" parameterType="TcYqzs" useGeneratedKeys="true" keyProperty="id">
        insert into tc_yqzs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="dateTime != null">date_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="count1 != null">count1,</if>
            <if test="count2 != null">count2,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="dateTime != null">#{dateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="count1 != null">#{count1},</if>
            <if test="count2 != null">#{count2},</if>
         </trim>
    </insert>

    <update id="updateTcYqzs" parameterType="TcYqzs">
        update tc_yqzs
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="dateTime != null">date_time = #{dateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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="count1 != null">count1 = #{count1},</if>
            <if test="count2 != null">count2 = #{count2},</if>
        </trim>
        where id = #{id}
    </update>


    <delete id="deleteTcYqzsById" parameterType="Long">
        delete from tc_yqzs where id = #{id}
    </delete>

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