<?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.CatalogueMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dlink.model.Catalogue">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="task_id" property="taskId" />
        <result column="type" property="type" />
        <result column="parent_id" property="parentId" />
        <result column="is_leaf" property="isLeaf" />
        <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, task_id, type,parent_id,is_leaf, enabled, create_time, update_time
    </sql>

    <select id="selectForProTable" resultType="com.dlink.model.Catalogue">
        select
        a.*
        from
        dlink_catalogue a
        <where>
            1=1
            <if test='param.name!=null and param.name!=""'>
                and a.name like "%${param.name}%"
            </if>
            <if test='param.task_id!=null and param.task_id!=""'>
                and a.task_id = #{param.task_id}
            </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>
