<?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="io.renren.modules.generator.dao.ImagesLogDao">
    <resultMap id="BaseResultMap" type="io.renren.modules.generator.entity.ImagesLogEntity">
        <id column="images_log_id" jdbcType="INTEGER" property="imagesLogId" />
        <result column="model_id" jdbcType="INTEGER" property="modelId" />
        <result column="images_log" jdbcType="LONGVARCHAR" property="imagesLog" />
    </resultMap>

    <sql id="Base_Column_List">
        images_log_id,model_id,images_log
    </sql>

    <insert id="insert" parameterType="io.renren.modules.generator.entity.ImagesLogEntity">
        insert into images_log(model_id,images_log)
        values (#{modelId,jdbcType=INTEGER},#{imagesLog,jdbcType=LONGVARCHAR})
    </insert>

    <select id="selectByModelId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from images_log
        where model_id=#{modelId,jdbcType=INTEGER}
        ORDER BY images_log_id DESC
        LIMIT 1
    </select>

    <delete id="delete" parameterType="java.lang.Integer">
        delete from images_log
        where model_id = #{modelId}
    </delete>
</mapper>