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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.BasicCardRule">
    <result column="id" property="id" />
        <result column="school_id" property="schoolId" />
        <result column="name" property="name" />
        <result column="exam_number_style" property="examNumberStyle" />
        <result column="exam_number_digit" property="examNumberDigit" />
        <result column="paper_type" property="paperType" />
        <result column="exam_absent" property="examAbsent" />
        <result column="write_sign" property="writeSign" />
        <result column="discipline" property="discipline" />
        <result column="undertaking_enable" property="undertakingEnable" />
        <result column="undertaking_body" property="undertakingBody" />
        <result column="required_fields" property="requiredFields" />
        <result column="extend_fields" property="extendFields" />
        <result column="fill_fields" property="fillFields" />
        <result column="title_rule" property="titleRule" />
        <result column="attention" property="attention" />
        <result column="objective_attention" property="objectiveAttention" />
        <result column="subjective_attention" property="subjectiveAttention" />
        <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" />
        <result column="fill_number" property="fillNumber" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        select id, school_id, name, exam_number_style,exam_number_digit, paper_type, exam_absent, write_sign, discipline,undertaking_enable, undertaking_body,required_fields, extend_fields,fill_fields, title_rule,first_level_subheading,second_level_subheading, attention, objective_attention, subjective_attention, enable, remark, create_id, create_time, update_id, update_time, fill_number from basic_card_rule
    </sql>
    <select id="listPage" resultType="com.qmth.distributed.print.business.entity.BasicCardRule">
        <include refid="Base_Column_List"></include>
        <where>
            <if test="schoolId != null and schoolId != ''">
                and school_id = #{schoolId}
            </if>
            <if test="enable != null and enable != ''">
                and enable = #{enable}
            </if>
            <if test="name != null and name != ''">
                and name like concat(#{name},'%')
            </if>
            <if test="createStartTime != null and createStartTime != ''">
                and create_time >= #{createStartTime}
            </if>
            <if test="createEndTime != null and createEndTime != ''">
                and create_time &lt;= #{createEndTime}
            </if>
            <if test="dpr != null">
                <if test="dpr.requestUserId != null">
                    AND create_id = #{dpr.requestUserId}
                </if>
                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
                    AND org_id IN
                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="list" resultMap="BaseResultMap">
        SELECT
            *
        FROM
            basic_card_rule a
        <where>
            AND a.school_id = #{schoolId}
--             AND a.enable = true
        </where>
        order by create_time desc
    </select>

</mapper>
