<?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.ejweb.modules.front.upload.dao.FrontUploadDao">
    <sql id="fileColumns">
      id,
      app_code,
      session_id,
      clientip,
      module,
      md5,
      name,
      input_name,
      path,
      thumbs,
      extesion,
      summary,
      size,
      width,
      orientataion,
      height
    </sql>
    <insert id="addUploadFile" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO ct_bbtc_upload_files(
            <include refid="fileColumns"/>
        ) VALUES(
            #{id},
            #{appCode},
            #{sessionId},
            #{clientip},
            #{module},
            #{md5},
            #{name},
            #{inputName},
            #{path},
            #{thumbs},
            #{extesion},
            #{summary},
            #{size},
            #{width},
            #{orientataion},
            #{height}
        )
    </insert>
    
    <select id="getUploadEntityByPath" resultType="com.ejweb.modules.upload.entity.UploadEntity">
        SELECT
        <include refid="fileColumns"/>
        FROM ct_bbtc_upload_files
        WHERE path = #{code}
        <if test="dbName == 'oracle'"> AND rownum &lt;= 1</if>
        ORDER BY created DESC
        <if test="dbName == 'mysql'"> limit 1</if>
    </select>
</mapper>