<?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.lframework.xingyun.core.mappers.OnlineExcelMapper">

  <resultMap id="OnlineExcel" type="com.lframework.xingyun.core.entity.OnlineExcel">
    <id column="id" property="id"/>
    <result column="name" property="name"/>
    <result column="content" property="content"/>
    <result column="available" property="available"/>
    <result column="description" property="description"/>
    <result column="create_by" property="createBy"/>
    <result column="create_time" property="createTime"/>
    <result column="update_by" property="updateBy"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>

  <select id="query" resultMap="OnlineExcel">
    <include refid="OnlineExcel_sql"/>
    <where>
      <if test="vo.name != null and vo.name != ''">
        AND tb.name LIKE CONCAT('%', #{vo.name}, '%')
      </if>
      <if test="vo.available != null">
        AND tb.available = #{vo.available}
      </if>
      <if test="vo.createTimeStart != null">
        AND tb.update_time >= #{vo.createTimeStart}
      </if>
      <if test="vo.createTimeEnd != null">
        <![CDATA[
        AND tb.update_time <= #{vo.createTimeEnd}
        ]]>
      </if>
      AND tb.create_by_id = #{createById}
    </where>
    ORDER BY tb.update_time DESC
  </select>

  <sql id="OnlineExcel_sql">
    SELECT tb.id,
           tb.name,
           tb.content,
           tb.available,
           tb.description,
           tb.create_by,
           tb.create_time,
           tb.update_by,
           tb.update_time
    FROM sw_online_excel AS tb
  </sql>
</mapper>
