<?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.datai.setting.mapper.DataiConfigAuditLogMapper">
    
    <resultMap type="DataiConfigAuditLog" id="DataiConfigAuditLogResult">
        <result property="id" column="id" />
        <result property="deptId" column="dept_id" />
        <result property="operationType" column="operation_type" />
        <result property="objectType" column="object_type" />
        <result property="objectId" column="object_id" />
        <result property="oldValue" column="old_value" />
        <result property="newValue" column="new_value" />
        <result property="operationDesc" column="operation_desc" />
        <result property="operator" column="operator" />
        <result property="operationTime" column="operation_time" />
        <result property="ipAddress" column="ip_address" />
        <result property="userAgent" column="user_agent" />
        <result property="requestId" column="request_id" />
        <result property="result" column="result" />
        <result property="errorMessage" column="error_message" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="updateBy" column="update_by" />
        <result property="updateTime" column="update_time" />
    </resultMap>

    <sql id="selectDataiConfigAuditLogVo">
        select 
            dcal.id,
            dcal.dept_id,
            dcal.operation_type,
            dcal.object_type,
            dcal.object_id,
            dcal.old_value,
            dcal.new_value,
            dcal.operation_desc,
            dcal.operator,
            dcal.operation_time,
            dcal.ip_address,
            dcal.user_agent,
            dcal.request_id,
            dcal.result,
            dcal.error_message,
            dcal.create_by,
            dcal.create_time,
            dcal.update_by,
            dcal.update_time
        from datai_config_audit_log dcal
    </sql>

    <select id="selectDataiConfigAuditLogList" parameterType="DataiConfigAuditLog" resultMap="DataiConfigAuditLogResult">
        <include refid="selectDataiConfigAuditLogVo"/>
        <where>
            <if test="deptId != null "> and dcal.dept_id = #{deptId}</if>
            <if test="operationType != null  and operationType != ''"> and dcal.operation_type = #{operationType}</if>
            <if test="objectType != null  and objectType != ''"> and dcal.object_type = #{objectType}</if>
            <if test="objectId != null "> and dcal.object_id = #{objectId}</if>
            <if test="oldValue != null  and oldValue != ''"> and dcal.old_value = #{oldValue}</if>
            <if test="newValue != null  and newValue != ''"> and dcal.new_value = #{newValue}</if>
            <if test="operationDesc != null  and operationDesc != ''"> and dcal.operation_desc = #{operationDesc}</if>
            <if test="operator != null  and operator != ''"> and dcal.operator = #{operator}</if>
            <if test="operationTime != null "> and dcal.operation_time = #{operationTime}</if>
            <if test="ipAddress != null  and ipAddress != ''"> and dcal.ip_address = #{ipAddress}</if>
            <if test="userAgent != null  and userAgent != ''"> and dcal.user_agent = #{userAgent}</if>
            <if test="requestId != null  and requestId != ''"> and dcal.request_id = #{requestId}</if>
            <if test="result != null  and result != ''"> and dcal.result = #{result}</if>
            <if test="errorMessage != null  and errorMessage != ''"> and dcal.error_message = #{errorMessage}</if>
        </where>
    </select>
    
    <select id="selectDataiConfigAuditLogById" parameterType="Long" resultMap="DataiConfigAuditLogResult">
        <include refid="selectDataiConfigAuditLogVo"/>
        where dcal.id = #{id}
    </select>
        
    <insert id="insertDataiConfigAuditLog" parameterType="DataiConfigAuditLog" useGeneratedKeys="true" keyProperty="id">
        insert into datai_config_audit_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="operationType != null and operationType != ''">operation_type,</if>
            <if test="objectType != null and objectType != ''">object_type,</if>
            <if test="objectId != null">object_id,</if>
            <if test="oldValue != null">old_value,</if>
            <if test="newValue != null">new_value,</if>
            <if test="operationDesc != null">operation_desc,</if>
            <if test="operator != null and operator != ''">operator,</if>
            <if test="operationTime != null">operation_time,</if>
            <if test="ipAddress != null">ip_address,</if>
            <if test="userAgent != null">user_agent,</if>
            <if test="requestId != null">request_id,</if>
            <if test="result != null and result != ''">result,</if>
            <if test="errorMessage != null">error_message,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="operationType != null and operationType != ''">#{operationType},</if>
            <if test="objectType != null and objectType != ''">#{objectType},</if>
            <if test="objectId != null">#{objectId},</if>
            <if test="oldValue != null">#{oldValue},</if>
            <if test="newValue != null">#{newValue},</if>
            <if test="operationDesc != null">#{operationDesc},</if>
            <if test="operator != null and operator != ''">#{operator},</if>
            <if test="operationTime != null">#{operationTime},</if>
            <if test="ipAddress != null">#{ipAddress},</if>
            <if test="userAgent != null">#{userAgent},</if>
            <if test="requestId != null">#{requestId},</if>
            <if test="result != null and result != ''">#{result},</if>
            <if test="errorMessage != null">#{errorMessage},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateDataiConfigAuditLog" parameterType="DataiConfigAuditLog">
        update datai_config_audit_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="operationType != null and operationType != ''">operation_type = #{operationType},</if>
            <if test="objectType != null and objectType != ''">object_type = #{objectType},</if>
            <if test="objectId != null">object_id = #{objectId},</if>
            <if test="oldValue != null">old_value = #{oldValue},</if>
            <if test="newValue != null">new_value = #{newValue},</if>
            <if test="operationDesc != null">operation_desc = #{operationDesc},</if>
            <if test="operator != null and operator != ''">operator = #{operator},</if>
            <if test="operationTime != null">operation_time = #{operationTime},</if>
            <if test="ipAddress != null">ip_address = #{ipAddress},</if>
            <if test="userAgent != null">user_agent = #{userAgent},</if>
            <if test="requestId != null">request_id = #{requestId},</if>
            <if test="result != null and result != ''">result = #{result},</if>
            <if test="errorMessage != null">error_message = #{errorMessage},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where datai_config_audit_log.id = #{id}
    </update>

    <delete id="deleteDataiConfigAuditLogById" parameterType="Long">
        delete from datai_config_audit_log where id = #{id}
    </delete>

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