<?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.dlink.mapper.DocumentMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dlink.model.Document">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="category" property="category" />
        <result column="type" property="type" />
        <result column="subtype" property="subtype" />
        <result column="description" property="description" />
        <result column="fill_value" property="fillValue" />
        <result column="version" property="version" />
        <result column="like_num" property="likeNum" />
        <result column="enabled" property="enabled" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, name, category, type,subtype,description, version,fill_value,like_num, enabled, create_time, update_time
    </sql>


    <select id="selectForProTable" resultType="com.dlink.model.Document">
        select
        a.*
        from
        dlink_flink_document a
        <where>
            1=1
            <if test='param.name!=null and param.name!=""'>
                and a.name like "%${param.name}%"
            </if>
            <if test='param.description!=null and param.description!=""'>
                and a.description like "%${param.description}%"
            </if>
            <if test='param.type!=null and param.type!=""'>
                and a.type = #{param.type}
            </if>
            <if test='param.subtype!=null and param.subtype!=""'>
                and a.subtype = #{param.subtype}
            </if>
            <if test='param.version!=null and param.version!=""'>
                and a.version = #{param.version}
            </if>
            <if test='param.createTime!=null and param.createTime!=""'>
                and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test='param.updateTime!=null and param.updateTime!=""'>
                and a.update_time <![CDATA[>=]]> str_to_date( #{param.updateTime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
                and
            </if>
            <if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
                ${ew.sqlSegment}
            </if>
        </where>
    </select>
</mapper>
