<?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.TcJbmapMapper">
    
    <resultMap type="TcJbmap" id="TcJbmapResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="isStatus"    column="isStatus"    />
        <result property="jbObj"    column="jb_obj"    />
        <result property="number"    column="number"    />
        <result property="jbTime"    column="jb_time"    />
        <result property="address"    column="address"    />
        <result property="content"    column="content"    />
        <result property="state"    column="state"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <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"    />
    </resultMap>

    <sql id="selectTcJbmapVo">
        select id, area_id, isStatus, jb_obj, number, jb_time, address, content, state, longitude, latitude, create_by, create_time, update_by, update_time, remark from tc_jbmap
    </sql>

    <select id="selectTcJbmapList" parameterType="TcJbmap" resultMap="TcJbmapResult">
        <include refid="selectTcJbmapVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="areaId != null  and areaId != ''"> and area_id = #{areaId}</if>
            <if test="jbObj != null  and jbObj != ''"> and jb_obj = #{jbObj}</if>
            <if test="isStatus != null "> and isStatus = #{isStatus}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="params.beginJbTime != null and params.beginJbTime != '' and params.endJbTime != null and params.endJbTime != ''"> and jb_time between #{params.beginJbTime} and #{params.endJbTime}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</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="remark != null  and remark != ''"> and remark = #{remark}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectTcJbmapById" parameterType="Long" resultMap="TcJbmapResult">
        <include refid="selectTcJbmapVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcJbmap" parameterType="TcJbmap" useGeneratedKeys="true" keyProperty="id">
        insert into tc_jbmap
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="isStatus != null">isStatus,</if>
            <if test="jbObj != null">jb_obj,</if>
            <if test="number != null">number,</if>
            <if test="jbTime != null">jb_time,</if>
            <if test="address != null">address,</if>
            <if test="content != null">content,</if>
            <if test="state != null">state,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="isStatus != null">#{isStatus},</if>
            <if test="jbObj != null">#{jbObj},</if>
            <if test="number != null">#{number},</if>
            <if test="jbTime != null">#{jbTime},</if>
            <if test="address != null">#{address},</if>
            <if test="content != null">#{content},</if>
            <if test="state != null">#{state},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</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>
         </trim>
    </insert>

    <update id="updateTcJbmap" parameterType="TcJbmap">
        update tc_jbmap
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="isStatus != null">isStatus = #{isStatus},</if>
            <if test="jbObj != null">jb_obj = #{jbObj},</if>
            <if test="number != null">number = #{number},</if>
            <if test="jbTime != null">jb_time = #{jbTime},</if>
            <if test="address != null">address = #{address},</if>
            <if test="content != null">content = #{content},</if>
            <if test="state != null">state = #{state},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</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>
        </trim>
        where id = #{id}
    </update>
    <update id="updateByisStatus">
        UPDATE tc_jbmap
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcJbmapById" parameterType="Long">
        delete from tc_jbmap where id = #{id}
    </delete>

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