<?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.my.bus.mapper.SysOperationLogMapper">

    <resultMap type="SysOperationLog" id="SysOperationLogResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="businessType" column="business_type"/>
        <result property="operContent" column="oper_content"/>
        <result property="operatorType" column="operator_type"/>
        <result property="operName" column="oper_name"/>
        <result property="deptName" column="dept_name"/>
        <result property="operUrl" column="oper_url"/>
        <result property="operIp" column="oper_ip"/>
        <result property="operLocation" column="oper_location"/>
        <result property="operParam" column="oper_param"/>
        <result property="jsonResult" column="json_result"/>
        <result property="status" column="status"/>
        <result property="errorMsg" column="error_msg"/>
        <result property="operTime" column="oper_time"/>
        <result property="costTime" column="cost_time"/>
    </resultMap>

    <sql id="baseVo">
        select id, title, business_type, oper_content, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time
        from BUS_SYS_OPERATION_LOG
    </sql>

    <select id="selectList" parameterType="SysOperationLog" resultMap="SysOperationLogResult">
        <include refid="baseVo"/>
        <where>
        <if test="title != null  and title != ''">
            and title = #{title}
        </if>
        <if test="businessType != null ">
            and business_type = #{businessType}
        </if>
        <if test="operContent != null  and operContent != ''">
            and oper_content = #{operContent}
        </if>
        <if test="operatorType != null ">
            and operator_type = #{operatorType}
        </if>
        <if test="operName != null  and operName != ''">
            and oper_name like concat('%', #{operName}, '%')
        </if>
        <if test="deptName != null  and deptName != ''">
            and dept_name like concat('%', #{deptName}, '%')
        </if>
        <if test="operUrl != null  and operUrl != ''">
            and oper_url = #{operUrl}
        </if>
        <if test="operIp != null  and operIp != ''">
            and oper_ip = #{operIp}
        </if>
        <if test="operLocation != null  and operLocation != ''">
            and oper_location = #{operLocation}
        </if>
        <if test="operParam != null  and operParam != ''">
            and oper_param = #{operParam}
        </if>
        <if test="jsonResult != null  and jsonResult != ''">
            and json_result = #{jsonResult}
        </if>
        <if test="status != null ">
            and status = #{status}
        </if>
        <if test="errorMsg != null  and errorMsg != ''">
            and error_msg = #{errorMsg}
        </if>
        <if test="operTime != null ">
            and oper_time = #{operTime}
        </if>
        <if test="costTime != null ">
            and cost_time = #{costTime}
        </if>
        </where>
    </select>

    <select id="selectById" parameterType="Long"
        resultMap="SysOperationLogResult">
        <include refid="baseVo"/>
        where id = #{id}
    </select>

    <insert id="insert" parameterType="SysOperationLog" useGeneratedKeys="true"
            keyProperty="id">
        insert into BUS_SYS_OPERATION_LOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,
            </if>
            <if test="businessType != null">business_type,
            </if>
            <if test="operContent != null">oper_content,
            </if>
            <if test="operatorType != null">operator_type,
            </if>
            <if test="operName != null">oper_name,
            </if>
            <if test="deptName != null">dept_name,
            </if>
            <if test="operUrl != null">oper_url,
            </if>
            <if test="operIp != null">oper_ip,
            </if>
            <if test="operLocation != null">oper_location,
            </if>
            <if test="operParam != null">oper_param,
            </if>
            <if test="jsonResult != null">json_result,
            </if>
            <if test="status != null">status,
            </if>
            <if test="errorMsg != null">error_msg,
            </if>
            <if test="operTime != null">oper_time,
            </if>
            <if test="costTime != null">cost_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},
            </if>
            <if test="businessType != null">#{businessType},
            </if>
            <if test="operContent != null">#{operContent},
            </if>
            <if test="operatorType != null">#{operatorType},
            </if>
            <if test="operName != null">#{operName},
            </if>
            <if test="deptName != null">#{deptName},
            </if>
            <if test="operUrl != null">#{operUrl},
            </if>
            <if test="operIp != null">#{operIp},
            </if>
            <if test="operLocation != null">#{operLocation},
            </if>
            <if test="operParam != null">#{operParam},
            </if>
            <if test="jsonResult != null">#{jsonResult},
            </if>
            <if test="status != null">#{status},
            </if>
            <if test="errorMsg != null">#{errorMsg},
            </if>
            <if test="operTime != null">#{operTime},
            </if>
            <if test="costTime != null">#{costTime},
            </if>
        </trim>
    </insert>

    <update id="update" parameterType="SysOperationLog">
        update BUS_SYS_OPERATION_LOG
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title =
                #{title},
            </if>
            <if test="businessType != null">business_type =
                #{businessType},
            </if>
            <if test="operContent != null">oper_content =
                #{operContent},
            </if>
            <if test="operatorType != null">operator_type =
                #{operatorType},
            </if>
            <if test="operName != null">oper_name =
                #{operName},
            </if>
            <if test="deptName != null">dept_name =
                #{deptName},
            </if>
            <if test="operUrl != null">oper_url =
                #{operUrl},
            </if>
            <if test="operIp != null">oper_ip =
                #{operIp},
            </if>
            <if test="operLocation != null">oper_location =
                #{operLocation},
            </if>
            <if test="operParam != null">oper_param =
                #{operParam},
            </if>
            <if test="jsonResult != null">json_result =
                #{jsonResult},
            </if>
            <if test="status != null">status =
                #{status},
            </if>
            <if test="errorMsg != null">error_msg =
                #{errorMsg},
            </if>
            <if test="operTime != null">oper_time =
                #{operTime},
            </if>
            <if test="costTime != null">cost_time =
                #{costTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteById" parameterType="Long">
        delete
        from BUS_SYS_OPERATION_LOG where id = #{id}
    </delete>

    <delete id="deleteByIds" parameterType="String">
        delete from BUS_SYS_OPERATION_LOG where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="logicDelete" parameterType="Long">
        update  BUS_SYS_OPERATION_LOG set del_flag = 1  where id = #{id}
    </delete>
</mapper>