<?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.teachcloud.common.mapper.BasicOperationLogMapper">

    <select id="findOperationLogPage"
            resultType="com.qmth.teachcloud.common.bean.result.BasicOperationLogResult">
        SELECT
            id,
            detail,
            user_id AS operatorId,
            user_name AS operatorName,
            ip,
            customized_operation_type AS customizedOperationType,
            create_time AS createTime
        FROM
            basic_operation_log
        <where>
            <if test="schoolId != null">
                AND school_id = #{schoolId}
            </if>
            <if test="customizedOperationType != null">
                AND customized_operation_type = #{customizedOperationType}
            </if>
            <if test="startTime != null">
                AND create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                AND #{endTime} >= create_time
            </if>
            <if test="operatorName != null and operatorName != ''">
                AND user_name LIKE CONCAT('%',#{operatorName},'%')
            </if>
            <if test="dpr != null">
                <if test="dpr.requestUserId != null">
                    AND user_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>
</mapper>