<?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="cn.timer.api.dao.qyzx.QyzxOperLogMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.qyzx.QyzxOperLog" >
                <result column="oper_id" property="operId" />
                <result column="org_code" property="orgCode" />
                <result column="emp_num" property="empNum" />
                <result column="title" property="title" />
                <result column="business_type" property="businessType" />
                <result column="method" property="method" />
                <result column="request_method" property="requestMethod" />
                <result column="operator_type" property="operatorType" />
                <result column="oper_name" property="operName" />
                <result column="dept_name" property="deptName" />
                <result column="oper_url" property="operUrl" />
                <result column="oper_ip" property="operIp" />
                <result column="oper_location" property="operLocation" />
                <result column="oper_param" property="operParam" />
                <result column="json_result" property="jsonResult" />
                <result column="status" property="status" />
                <result column="error_msg" property="errorMsg" />
                <result column="oper_time" property="operTime" />
    </resultMap>

    <sql id="Base_Column_List">
                oper_id,
                org_code,
                emp_num,
                title,
                business_type,
                method,
                request_method,
                operator_type,
                oper_name,
                dept_name,
                oper_url,
                oper_ip,
                oper_location,
                <!-- oper_param, -->
                <!-- json_result, -->
                status,
                error_msg,
                oper_time
    </sql>
    
    <sql id="Base_Column_List_Alias">
                oper_id QyzxOperLog_oper_id,
                org_code QyzxOperLog_org_code,
                emp_num QyzxOperLog_emp_num,
                title QyzxOperLog_title,
                business_type QyzxOperLog_business_type,
                method QyzxOperLog_method,
                request_method QyzxOperLog_request_method,
                operator_type QyzxOperLog_operator_type,
                oper_name QyzxOperLog_oper_name,
                dept_name QyzxOperLog_dept_name,
                oper_url QyzxOperLog_oper_url,
                oper_ip QyzxOperLog_oper_ip,
                oper_location QyzxOperLog_oper_location,
                oper_param QyzxOperLog_oper_param,
                json_result QyzxOperLog_json_result,
                status QyzxOperLog_status,
                error_msg QyzxOperLog_error_msg,
                oper_time QyzxOperLog_oper_time
    </sql>


	<select id="selectPageByQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_oper_log a
        WHERE a.org_code = #{param.orgCode} 
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.oper_name like CONCAT('%',#{param.query},'%') or
        			a.oper_id like CONCAT('%',#{param.query},'%') 
        		)
        	</if>
        	<if test="param.businessType != null">
        		and a.business_type = #{param.businessType}
			</if>
        	<if test="param.operatorType != null">
        		and a.operator_type = #{param.operatorType}
			</if>
        	<if test="param.requestMethod != null">
        		and a.request_method = #{param.requestMethod}
			</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.oper_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
        		and a.oper_time <![CDATA[ <= ]]> #{param.endTime}
        	</if>
        ORDER BY a.oper_time DESC
    </select>

	<select id="selectPageByQuery2" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_oper_log a
        WHERE a.org_code = #{param.orgCode} 
        
        <if test="param.empNums != null and param.empNums.size() > 0">
        		<choose>
					<when test="param.empNums.size() > 1">
						AND a.emp_num IN 
						(
						<foreach item="it" index="index" collection="param.empNums" separator="," close="" >
				        	#{it}
						</foreach>
						) 
					</when>
					<otherwise>
						AND a.emp_num = #{param.empNums[0]}
					</otherwise>
				</choose>
        	</if>
        
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.oper_name like CONCAT('%',#{param.query},'%') or
        			a.oper_id like CONCAT('%',#{param.query},'%') 
        		)
        	</if>
        	<if test="param.businessType != null">
        		and a.business_type = #{param.businessType}
			</if>
        	<if test="param.operatorType != null">
        		and a.operator_type = #{param.operatorType}
			</if>
        	<if test="param.requestMethod != null">
        		and a.request_method = #{param.requestMethod}
			</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.oper_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
        		and a.oper_time <![CDATA[ <= ]]> #{param.endTime}
        	</if>
        ORDER BY a.oper_time DESC
    </select>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.qyzx.QyzxOperLog">
        INSERT INTO qyzx_oper_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != operId'>
                        oper_id,
                        </if>
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != empNum'>
                        emp_num,
                        </if>
                        <if test ='null != title'>
                        title,
                        </if>
                        <if test ='null != businessType'>
                        business_type,
                        </if>
                        <if test ='null != method'>
                        method,
                        </if>
                        <if test ='null != requestMethod'>
                        request_method,
                        </if>
                        <if test ='null != operatorType'>
                        operator_type,
                        </if>
                        <if test ='null != operName'>
                        oper_name,
                        </if>
                        <if test ='null != deptName'>
                        dept_name,
                        </if>
                        <if test ='null != operUrl'>
                        oper_url,
                        </if>
                        <if test ='null != operIp'>
                        oper_ip,
                        </if>
                        <if test ='null != operLocation'>
                        oper_location,
                        </if>
                        <if test ='null != operParam'>
                        oper_param,
                        </if>
                        <if test ='null != jsonResult'>
                        json_result,
                        </if>
                        <if test ='null != status'>
                        status,
                        </if>
                        <if test ='null != errorMsg'>
                        error_msg,
                        </if>
                        <if test ='null != operTime'>
                        oper_time
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != operId'>
                        #{operId},
                        </if>
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != empNum'>
                        #{empNum},
                        </if>
                        <if test ='null != title'>
                        #{title},
                        </if>
                        <if test ='null != businessType'>
                        #{businessType},
                        </if>
                        <if test ='null != method'>
                        #{method},
                        </if>
                        <if test ='null != requestMethod'>
                        #{requestMethod},
                        </if>
                        <if test ='null != operatorType'>
                        #{operatorType},
                        </if>
                        <if test ='null != operName'>
                        #{operName},
                        </if>
                        <if test ='null != deptName'>
                        #{deptName},
                        </if>
                        <if test ='null != operUrl'>
                        #{operUrl},
                        </if>
                        <if test ='null != operIp'>
                        #{operIp},
                        </if>
                        <if test ='null != operLocation'>
                        #{operLocation},
                        </if>
                        <if test ='null != operParam'>
                        #{operParam},
                        </if>
                        <if test ='null != jsonResult'>
                        #{jsonResult},
                        </if>
                        <if test ='null != status'>
                        #{status},
                        </if>
                        <if test ='null != errorMsg'>
                        #{errorMsg},
                        </if>
                        <if test ='null != operTime'>
                        #{operTime}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM qyzx_oper_log
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.qyzx.QyzxOperLog">
        UPDATE qyzx_oper_log
        <set>
                    <if test ='null != operId'>oper_id = #{operId},</if>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != empNum'>emp_num = #{empNum},</if>
                    <if test ='null != title'>title = #{title},</if>
                    <if test ='null != businessType'>business_type = #{businessType},</if>
                    <if test ='null != method'>method = #{method},</if>
                    <if test ='null != requestMethod'>request_method = #{requestMethod},</if>
                    <if test ='null != operatorType'>operator_type = #{operatorType},</if>
                    <if test ='null != operName'>oper_name = #{operName},</if>
                    <if test ='null != deptName'>dept_name = #{deptName},</if>
                    <if test ='null != operUrl'>oper_url = #{operUrl},</if>
                    <if test ='null != operIp'>oper_ip = #{operIp},</if>
                    <if test ='null != operLocation'>oper_location = #{operLocation},</if>
                    <if test ='null != operParam'>oper_param = #{operParam},</if>
                    <if test ='null != jsonResult'>json_result = #{jsonResult},</if>
                    <if test ='null != status'>status = #{status},</if>
                    <if test ='null != errorMsg'>error_msg = #{errorMsg},</if>
                    <if test ='null != operTime'>oper_time = #{operTime}</if>
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_oper_log
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_oper_log
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM qyzx_oper_log
    </select>

	 -->

</mapper>