<?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.djhk.uav.plotting.mapper.PlottingMapper">

    <resultMap type="com.djhk.uav.plotting.modol.Plotting" id="PlottingResult">
        <result property="id"    column="id"    />
        <result property="plottingJson"    column="plotting_json"    />
        <result property="plottingTitle"    column="plotting_title"    />
        <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="sysDeptNo"    column="sys_dept_no"    />
    </resultMap>

    <sql id="selectPlottingVo">
        select id,plotting_json, plotting_title, create_by, create_time, update_by, update_time, sys_dept_no from plotting_json
    </sql>

    <select id="selectPlottingList" parameterType="com.djhk.uav.plotting.modol.Plotting" resultMap="PlottingResult">
        <include refid="selectPlottingVo"/>
        where sys_dept_no = #{sysDeptNo}
        ORDER BY id DESC LIMIT 1
    </select>

    <select id="selectPlottingById" parameterType="Long" resultMap="PlottingResult">
        <include refid="selectPlottingVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlotting" parameterType="com.djhk.uav.plotting.modol.Plotting">
        insert into plotting_json
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plottingJson != null">plotting_json,</if>
            <if test="plottingTitle != null">plotting_title,</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="sysDeptNo != null">sys_dept_no,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plottingJson != null">#{plottingJson},</if>
            <if test="plottingTitle != null">#{plottingTitle},</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="sysDeptNo != null"> #{sysDeptNo},</if>
        </trim>
    </insert>

    <update id="updatePlotting" parameterType="com.djhk.uav.plotting.modol.Plotting">
        update plotting_json
        <trim prefix="SET" suffixOverrides=",">
            <if test="plottingJson != null">plotting_json = #{plottingJson},</if>
            <if test="plottingTitle != null">plotting_title = #{plottingTitle},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlottingById" parameterType="Long">
        delete from plotting_json where id = #{id}
    </delete>

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