<?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.inspect.metadata.montdata.mapper.BasedataMontPatDevCoordMapper">

    <resultMap type="BasedataMontPatDevCoord" id="BasedataMontPatDevCoordResult">
        <result property="coordId" column="coord_id"/>
        <result property="eqpBookId" column="eqp_book_id"/>
        <result property="patrolDeviceCode" column="patrol_device_code"/>
        <result property="patrolDeviceName" column="patrol_device_name"/>
        <result property="time" column="time"/>
        <result property="coordinatePixel" column="coord_pixel"/>
        <result property="coordinateGeography" column="coord_geography"/>
        <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="deleteFlag" column="delete_flag"/>
    </resultMap>

    <sql id="selectBasedataMontPatDevCoordVo">
        select coord_id,
               eqp_book_id,
               patrol_device_code,
               patrol_device_name, time, coord_pixel, coord_geography, create_by, create_time, update_by, update_time, delete_flag
        from basedata_mont_patdevcoord
    </sql>

    <select id="selectBasedataMontPatDevCoordList" parameterType="BasedataMontPatDevCoord"
            resultMap="BasedataMontPatDevCoordResult">
        <include refid="selectBasedataMontPatDevCoordVo"/>
        <where>
            <if test="eqpBookId != null ">and eqp_book_id = #{eqpBookId}</if>
            <if test="patrolDeviceCode != null  and patrolDeviceCode != ''">and patrol_device_code =
                #{patrolDeviceCode}
            </if>
            <if test="patrolDeviceName != null  and patrolDeviceName != ''">and patrol_device_name like concat('%',
                #{patrolDeviceName}, '%')
            </if>
            <if test="time != null  and time != ''">and time = #{time}</if>
            <if test="coordPixel != null  and coordPixel != ''">and coord_pixel = #{coordPixel}
            </if>
            <if test="coordGeography != null  and coordGeography != ''">and coord_geography =
                #{coordGeography}
            </if>
            <if test="deleteFlag != null  and deleteFlag != ''">and delete_flag = #{deleteFlag}</if>
        </where>
    </select>

    <select id="selectBasedataMontPatDevCoordByMontPatDevCoordId" parameterType="Long"
            resultMap="BasedataMontPatDevCoordResult">
        <include refid="selectBasedataMontPatDevCoordVo"/>
        where coord_id = #{coordId}
    </select>

    <insert id="insertBasedataMontPatDevCoord" parameterType="BasedataMontPatDevCoord" useGeneratedKeys="true"
            keyProperty="coordId">
        insert into basedata_mont_patdevcoord
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eqpBookId != null">eqp_book_id,</if>
            <if test="patrolDeviceCode != null">patrol_device_code,</if>
            <if test="patrolDeviceName != null">patrol_device_name,</if>
            <if test="time != null">time,</if>
            <if test="coordPixel != null">coord_pixel,</if>
            <if test="coordGeography != null">coord_geography,</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="deleteFlag != null">delete_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="eqpBookId != null">#{eqpBookId},</if>
            <if test="patrolDeviceCode != null">#{patrolDeviceCode},</if>
            <if test="patrolDeviceName != null">#{patrolDeviceName},</if>
            <if test="time != null">#{time},</if>
            <if test="coordPixel != null">#{coordPixel},</if>
            <if test="coordGeography != null">#{coordGeography},</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="deleteFlag != null">#{deleteFlag},</if>
        </trim>
    </insert>

    <update id="updateBasedataMontPatDevCoord" parameterType="BasedataMontPatDevCoord">
        update basedata_mont_patdevcoord
        <trim prefix="SET" suffixOverrides=",">
            <if test="eqpBookId != null">eqp_book_id = #{eqpBookId},</if>
            <if test="patrolDeviceCode != null">patrol_device_code = #{patrolDeviceCode},</if>
            <if test="patrolDeviceName != null">patrol_device_name = #{patrolDeviceName},</if>
            <if test="time != null">time = #{time},</if>
            <if test="coordPixel != null">coord_pixel = #{coordPixel},</if>
            <if test="coordGeography != null">coord_geography = #{coordGeography},</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="deleteFlag != null">delete_flag = #{deleteFlag},</if>
        </trim>
        where coord_id = #{coordId}
    </update>

    <delete id="deleteBasedataMontPatDevCoordByMontPatDevCoordId" parameterType="Long">
        delete
        from basedata_mont_patdevcoord
        where coord_id = #{coordId}
    </delete>

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