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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.common.entity.BasicPrintConfig">
        <result column="id" property="id" />
        <result column="school_id" property="schoolId" />
        <result column="enable" property="enable" />
        <result column="review" property="review" />
        <result column="print_method" property="printMethod" />
        <result column="card_rule_id" property="cardRuleId" />
        <result column="print_content" property="printContent" />
        <result column="backup_method" property="backupMethod" />
        <result column="backup_count" property="backupCount" />
        <result column="draw_rule" property="drawRule" />
        <result column="variable_content" property="variableContent" />
        <result column="ordinary_content" property="ordinaryContent" />
        <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, enable,review, print_method, card_rule_id, print_content, backup_method, backup_count, draw_rule, variable_content, ordinary_content, create_id, create_time, update_id, update_time
    </sql>

    <select id="listPage" resultMap="BaseResultMap">
        select * from basic_print_config
        <where>
            <if test="schoolId != null and schoolId != ''">
                and school_id = #{schoolId}
            </if>
            <if test="examId != null and examId != ''">
                and exam_id = #{examId}
            </if>
            <if test="enable != null and enable != '' or enable == 0">
                and enable = #{enable}
            </if>
            <if test="createStartTime != null and createStartTime != ''">
                and create_time &gt;= #{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>
    </select>
    <select id="getBySchoolIdAndExamId" resultMap="BaseResultMap">
        SELECT
            *
        FROM
            basic_print_config a
        WHERE
            a.school_id = #{schoolId}
          AND a.exam_id = #{examId}
    </select>
</mapper>