<?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.ruoyi.base.mapper.RobotOpsSysLogMapper">
    
    <resultMap type="RobotOpsSysLog" id="RobotOpsSysLogResult">
        <result property="id"    column="id"    />
        <result property="robotCode"    column="robot_code"    />
        <result property="logTime"    column="log_time"    />
        <result property="receiveTime"    column="receive_time"    />
        <result property="logType"    column="log_type"    />
        <result property="logLevel"    column="log_level"    />
        <result property="moduleName"    column="module_name"    />
        <result property="contentSummary"    column="content_summary"    />
        <result property="content"    column="content"    />
        <result property="resultStatus"    column="result_status"    />
        <result property="traceId"    column="trace_id"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRobotOpsSysLogVo">
        select id, robot_code, log_time, receive_time, log_type, log_level, module_name, content_summary, content, result_status, trace_id, remark, create_time from robot_ops_sys_log
    </sql>

    <select id="selectRobotOpsSysLogList" parameterType="RobotOpsSysLog" resultMap="RobotOpsSysLogResult">
        <include refid="selectRobotOpsSysLogVo"/>
        <where>  
            <if test="robotCode != null  and robotCode != ''"> and robot_code = #{robotCode}</if>
            <if test="logTime != null "> and log_time = #{logTime}</if>
            <if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
            <if test="logType != null  and logType != ''"> and log_type = #{logType}</if>
            <if test="logLevel != null  and logLevel != ''"> and log_level = #{logLevel}</if>
            <if test="moduleName != null  and moduleName != ''"> and module_name like concat('%', #{moduleName}, '%')</if>
            <if test="contentSummary != null  and contentSummary != ''"> and content_summary = #{contentSummary}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="resultStatus != null  and resultStatus != ''"> and result_status = #{resultStatus}</if>
            <if test="traceId != null  and traceId != ''"> and trace_id = #{traceId}</if>
        </where>
    </select>
    
    <select id="selectRobotOpsSysLogById" parameterType="Long" resultMap="RobotOpsSysLogResult">
        <include refid="selectRobotOpsSysLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsSysLog" parameterType="RobotOpsSysLog" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_sys_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="robotCode != null">robot_code,</if>
            <if test="logTime != null">log_time,</if>
            <if test="receiveTime != null">receive_time,</if>
            <if test="logType != null">log_type,</if>
            <if test="logLevel != null">log_level,</if>
            <if test="moduleName != null">module_name,</if>
            <if test="contentSummary != null">content_summary,</if>
            <if test="content != null">content,</if>
            <if test="resultStatus != null">result_status,</if>
            <if test="traceId != null">trace_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="robotCode != null">#{robotCode},</if>
            <if test="logTime != null">#{logTime},</if>
            <if test="receiveTime != null">#{receiveTime},</if>
            <if test="logType != null">#{logType},</if>
            <if test="logLevel != null">#{logLevel},</if>
            <if test="moduleName != null">#{moduleName},</if>
            <if test="contentSummary != null">#{contentSummary},</if>
            <if test="content != null">#{content},</if>
            <if test="resultStatus != null">#{resultStatus},</if>
            <if test="traceId != null">#{traceId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRobotOpsSysLog" parameterType="RobotOpsSysLog">
        update robot_ops_sys_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="robotCode != null">robot_code = #{robotCode},</if>
            <if test="logTime != null">log_time = #{logTime},</if>
            <if test="receiveTime != null">receive_time = #{receiveTime},</if>
            <if test="logType != null">log_type = #{logType},</if>
            <if test="logLevel != null">log_level = #{logLevel},</if>
            <if test="moduleName != null">module_name = #{moduleName},</if>
            <if test="contentSummary != null">content_summary = #{contentSummary},</if>
            <if test="content != null">content = #{content},</if>
            <if test="resultStatus != null">result_status = #{resultStatus},</if>
            <if test="traceId != null">trace_id = #{traceId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsSysLogById" parameterType="Long">
        delete from robot_ops_sys_log where id = #{id}
    </delete>

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