<?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="cn.reghao.tnb.sb.multi.mybatis.mapper.two.CameraPhotoMapper">
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into geo_camera_photo
        (`from`,`album_id`,`object_id`,`channel_id`,`photo_url`,`manufacturer`,`model`,`software`,`shot_at`,`geo`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.from},#{item.albumId},#{item.objectId},#{item.channelId},#{item.photoUrl},#{item.manufacturer},#{item.model},#{item.software},#{item.shotAt},point(#{item.longitude},#{item.latitude}))
        </foreach>
    </insert>

    <update id="updateSetDeleted">
        update geo_camera_photo
        set deleted=1
        where object_id=#{objectId}
    </update>
    <update id="updateSetFrom">
        update geo_camera_photo
        set `from`=#{from}
        where object_id=#{objectId}
    </update>
    <update id="updateBatch">
        update geo_camera_photo
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="deleted=1" suffix="end,">
            </trim>
        </trim>
        <where>
            object_id in
            <foreach collection="list" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </where>
    </update>

    <select id="findAll" resultType="cn.reghao.tnb.sb.multi.mybatis.model.two.CameraPhoto">
        select *
        from geo_camera_photo
    </select>
</mapper>