<?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.nantian.sc.cloud.admin.mapper.OperationLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.sc.cloud.admin.api.entity.OperationLog">
        <id column="id" property="id" />
        <result column="module" property="module" />
        <result column="action" property="action" />
        <result column="method" property="method" />
        <result column="remark" property="remark" />
        <result column="request_uri" property="requestUri" />
        <result column="remote_addr" property="remoteAddr" />
        <result column="user_agent" property="userAgent" />
        <result column="user_id" property="userId" />
        <result column="user_name" property="userName" />
        <result column="user_real_name" property="userRealName" />
        <result column="user_dept" property="userDept" />
        <result column="dept_id" property="deptId" />
        <result column="run_time" property="runTime" />
        <result column="creat_time" property="creatTime" />
        <result column="return_value" property="returnValue" />
    </resultMap>

    <sql id="Base_Column_List">
        id, module, action, method, remark, request_uri, remote_addr, user_agent, user_id, user_name, user_real_name, user_dept, dept_id, run_time, creat_time, return_value
    </sql>

    <select id="getPageScope" resultType="com.nantian.sc.cloud.admin.api.entity.OperationLog">
        select <include refid="Base_Column_List"></include>
        from operation_log
        <trim prefix="where" prefixOverrides="and">
            <if test="log.userDept != null and log.userDept != '' and log.userDept != '0'.toString()">
                and user_dept like concat("%",#{log.userDept},"%")
            </if>
            <if test="deptId != null and deptId != ''">
                and dept_id like concat("%",#{deptId},"%")
            </if>
            <if test="log.module != null and log.module != ''">
                and module like concat("%",#{log.module},"%")
            </if>
            <if test="log.action != null and log.action != ''">
                and action like concat("%",#{log.action},"%")
            </if>
            <if test="log.method != null and log.method != ''">
                and method like concat("%",#{log.method},"%")
            </if>
            <if test="log.remark != null and log.remark != ''">
                and remark like concat("%",#{log.remark},"%")
            </if>
            <if test="log.userName != null and log.userName != ''">
                and user_name like concat("%",#{log.userName},"%")
            </if>
            <if test="log.userRealName != null and log.userRealName != ''">
                and user_real_name like concat("%",#{log.userRealName},"%")
            </if>
        </trim>
        order by creat_time desc
    </select>

</mapper>
