<?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.huijy.management.mapper.MemberLocationMapper">
    
    <resultMap type="MemberLocation" id="MemberLocationResult">
        <result property="memberLocationId"    column="member_location_id"    />
        <result property="memberId"    column="member_id"    />
        <result property="lat"    column="lat"    />
        <result property="lng"    column="lng"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectMemberLocationVo">
        select member_location_id, member_id, lat, lng, create_time from t_member_location
    </sql>

    <select id="selectMemberLocationList" parameterType="MemberLocation" resultMap="MemberLocationResult">
        <include refid="selectMemberLocationVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectMemberLocationByMemberLocationId" parameterType="Long" resultMap="MemberLocationResult">
        <include refid="selectMemberLocationVo"/>
        where member_location_id = #{memberLocationId}
    </select>
        
    <insert id="insertMemberLocation" parameterType="MemberLocation" useGeneratedKeys="true" keyProperty="memberLocationId">
        insert into t_member_location
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="memberId != null">member_id,</if>
            <if test="lat != null">lat,</if>
            <if test="lng != null">lng,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="memberId != null">#{memberId},</if>
            <if test="lat != null">#{lat},</if>
            <if test="lng != null">#{lng},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateMemberLocation" parameterType="MemberLocation">
        update t_member_location
        <trim prefix="SET" suffixOverrides=",">
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="lat != null">lat = #{lat},</if>
            <if test="lng != null">lng = #{lng},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where member_location_id = #{memberLocationId}
    </update>

    <delete id="deleteMemberLocationByMemberLocationId" parameterType="Long">
        delete from t_member_location where member_location_id = #{memberLocationId}
    </delete>

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