<?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.project.monitor.job.mapper.JobLogMapper">

	<resultMap type="JobLog" id="JobLogResult">
		<id     property="jobLogId"       column="job_log_id"      />
		<result property="jobName"        column="job_name"        />
		<result property="jobGroup"       column="job_group"       />
		<result property="methodName"     column="method_name"     />
		<result property="params"         column="params"          />
		<result property="jobMessage"     column="job_message"     />
		<result property="isException"    column="is_exception"    />
		<result property="exceptionInfo"  column="exception_info"  />
		<result property="createTime"     column="create_time"     />
	</resultMap>
	
	<select id="selectJobLogList" parameterType="JobLog" resultMap="JobLogResult">
		select * from sys_job_log
		<where>
			<if test="searchValue != null and searchValue != ''">
				AND job_name like concat(concat('%', #{searchValue}), '%') OR method_name like concat(concat('%', #{searchValue}), '%')
			</if>
		</where>
	</select>
	
	<select id="selectJobAll" resultMap="JobLogResult">
		SELECT * FROM sys_job_log
	</select>
	
	<select id="selectJobLogById" parameterType="Long" resultMap="JobLogResult">
		select *
		from sys_job_log u
		where u.job_log_id = #{jobLogId}
	</select>
	
	<delete id="deleteJobLogById" parameterType="Long">
 		delete from sys_job_log where job_log_id = #{jobLogId}
 	</delete>
 	
 	<delete id="batchDeleteJobLog" parameterType="Long">
 		delete from sys_job_log where job_log_id in
 		<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
 			#{jobLogId}
        </foreach> 
 	</delete>
 	
 	<insert id="insertJobLog" parameterType="JobLog">
 		insert into sys_job_log(
 			<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
 			<if test="jobName != null and jobName != ''">job_name,</if>
 			<if test="jobGroup != null and jobGroup != ''">job_group,</if>
 			<if test="methodName != null and methodName != ''">method_name,</if>
 			<if test="params != null and params != ''">params,</if>
 			<if test="jobMessage != null and jobMessage != ''">job_message,</if>
 			<if test="isException != null and isException != ''">is_exception,</if>
 			<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
 			create_time
 		)values(
 			<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
 			<if test="jobName != null and jobName != ''">#{jobName},</if>
 			<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
 			<if test="methodName != null and methodName != ''">#{methodName},</if>
 			<if test="params != null and params != ''">#{params},</if>
 			<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
 			<if test="isException != null and isException != ''">#{isException},</if>
 			<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
 			sysdate()
 		)
	</insert>

</mapper> 