<?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.huashe.park.core.mapper.ParkInspectProjMapper">

    <resultMap type="ParkInspectProj" id="ParkInspectProjResult">
        <result property="id" column="id"/>
        <result property="projContent" column="proj_content"/>
        <result property="lng" column="lng"/>
        <result property="lat" column="lat"/>
        <result property="radius" column="radius"/>
        <result property="projType" column="proj_type"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="tenantId" column="tenant_id"/>
    </resultMap>

    <sql id="selectParkInspectProjVo">
        select id,
               proj_content,
               lng,
               lat,
               radius,
               proj_type,
               update_time,
               create_time,
               create_by,
               update_by,
               tenant_id
        from park_inspect_proj
    </sql>

    <select id="selectParkInspectProjList" parameterType="ParkInspectProj" resultMap="ParkInspectProjResult">
        <include refid="selectParkInspectProjVo"/>
        <where>
            <if test="projContent != null  and projContent != ''">and proj_content = #{projContent}</if>
            <if test="projType != null  and projType != ''">and proj_type = #{projType}</if>
        </where>
    </select>

    <select id="selectParkInspectProjById" parameterType="Long" resultMap="ParkInspectProjResult">
        <include refid="selectParkInspectProjVo"/>
        where id = #{id}
    </select>

    <insert id="insertParkInspectProj" parameterType="ParkInspectProj" useGeneratedKeys="true" keyProperty="id">
        insert into park_inspect_proj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projContent != null">proj_content,</if>
            <if test="lng != null">lng,</if>
            <if test="lat != null">lat,</if>
            <if test="radius != null">radius,</if>
            <if test="projType != null">proj_type,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="tenantId != null">tenant_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projContent != null">
                #{projContent},
            </if>
            <if test="lng != null">#{lng},</if>
            <if test="lat != null">#{lat},</if>
            <if test="radius != null">#{radius},</if>
            <if test="projType != null">#{projType},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="tenantId != null">#{tenantId},</if>
        </trim>
    </insert>

    <update id="updateParkInspectProj" parameterType="ParkInspectProj">
        update park_inspect_proj
        <trim prefix="SET" suffixOverrides=",">
            <if test="projContent != null">proj_content = #{projContent},</if>
            <if test="lng != null">lng = #{lng},</if>
            <if test="lat != null">lat = #{lat},</if>
            <if test="radius != null">radius = #{radius},</if>
            <if test="projType != null">proj_type = #{projType},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteParkInspectProjById" parameterType="Long">
        delete
        from park_inspect_proj
        where id = #{id}
    </delete>

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