<?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.qmth.distributed.print.business.mapper.BasicTemplateMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.BasicTemplate">
    <result column="id" property="id" />
        <result column="school_id" property="schoolId" />
        <result column="name" property="name" />
        <result column="type" property="type" />
        <result column="classify" property="classify" />
        <result column="attachment_id" property="attachmentId" />
        <result column="enable" property="enable" />
        <result column="remark" property="remark" />
        <result column="create_id" property="createId" />
        <result column="create_time" property="createTime" />
        <result column="update_id" property="updateId" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        school_id, name, type, classify, attachment_id, enable, remark, create_id, create_time, update_id, update_time
    </sql>
    <select id="listPage" resultType="com.qmth.distributed.print.business.bean.dto.TemplateDto">
        SELECT
            id,
            school_id schoolId,
            name,
            type,
            classify,
            attachment_id attachmentId,
            enable,
            remark,
            create_id createId,
            create_time createTime
        FROM
            basic_template
        <where>
            <if test="schoolId != null and schoolId != ''">
                and school_id = #{schoolId}
            </if>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="name != null and name != ''">
                and name like concat('%',#{name}, '%')
            </if>
            <if test="enable != null">
                and enable = #{enable}
            </if>
            <if test="startTime != null and startTime != ''">
                and create_time &gt;= #{startTime}
            </if>
            <if test="endTime != null and endTime != ''">
                and create_time &lt;= #{endTime}
            </if>
        </where>
        order by create_time desc
    </select>

</mapper>
