<?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="me.zhengjie.mapper.QiniuContentMapper">

    <resultMap id="BaseResultMap" type="me.zhengjie.domain.QiniuContent">
        <id column="content_id" property="id" jdbcType="BIGINT"/>
        <result column="name" property="key" jdbcType="VARCHAR"/>
        <result column="size" property="size" jdbcType="VARCHAR"/>
        <result column="type" property="type" jdbcType="VARCHAR"/>
        <result column="suffix" property="suffix" jdbcType="VARCHAR"/>
        <result column="bucket" property="bucket" jdbcType="VARCHAR"/>
        <result column="url" property="url" jdbcType="VARCHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        content_id, name, size, type, suffix, bucket, url, update_time
    </sql>

    <select id="findByKey" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tool_qiniu_content
        WHERE name = #{name}
    </select>

    <select id="findAll" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM tool_qiniu_content
        <where>
            <if test="criteria.key != null and criteria.key != ''">
                AND name LIKE CONCAT('%',#{criteria.key},'%')
            </if>
            <if test="criteria.createTime != null and criteria.createTime.size() > 0">
                AND update_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
            </if>
        </where>
        ORDER BY content_id DESC
    </select>
</mapper>