<?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.model.mapper.AppletAddressMapper">

    <resultMap type="AppletAddress" id="AppletAddressResult">
        <result property="id" column="id"/>
        <result property="area" column="area"/>
        <result property="address" column="address"/>
        <result property="status" column="status"/>
        <result property="rangeNo" column="range_no"/>
        <result property="userId" column="user_id"/>
        <result property="delFlag" column="del_flag"/>
        <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="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
    </resultMap>

    <sql id="selectAppletAddressVo">
        select id, area, address, status, range_no, user_id, del_flag, create_by, create_time, update_by, update_time, longitude, latitude  from applet_address    </sql>

    <select id="selectAppletAddressList" parameterType="AppletAddress" resultMap="AppletAddressResult">
        <include refid="selectAppletAddressVo"/>
        <where>
            <if test="area != null  and area != ''"> and area = #{area}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="rangeNo != null  and rangeNo != ''"> and range_no = #{rangeNo}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>

    <select id="selectAppletAddressById" parameterType="AppletAddress" resultMap="AppletAddressResult">
        <include refid="selectAppletAddressVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppletAddress" parameterType="AppletAddress" useGeneratedKeys="true" keyProperty="id">
        insert into applet_address
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="area != null">area,</if>
            <if test="address != null">address,</if>
            <if test="status != null">status,</if>
            <if test="rangeNo != null">range_no,</if>
            <if test="userId != null">user_id,</if>
            <if test="delFlag != null">del_flag,</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="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="area != null">#{area},</if>
            <if test="address != null">#{address},</if>
            <if test="status != null">#{status},</if>
            <if test="rangeNo != null">#{rangeNo},</if>
            <if test="userId != null">#{userId},</if>
            <if test="delFlag != null">#{delFlag},</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="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
        </trim>
    </insert>

    <update id="updateAppletAddress" parameterType="AppletAddress">
        update applet_address
        <trim prefix="SET" suffixOverrides=",">
            <if test="area != null">area = #{area},</if>
            <if test="address != null">address = #{address},</if>
            <if test="status != null">status = #{status},</if>
            <if test="rangeNo != null">range_no = #{rangeNo},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppletAddressById" parameterType="Long">
        delete from applet_address where id = #{id}
    </delete>

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