JobLogMapper.xml 3.64 KB
<?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.huaheng.pc.monitor.job.mapper.JobLogMapper">

	<resultMap type="com.huaheng.pc.monitor.job.domain.JobLog" id="JobLogResult">
		<id     property="id"       column="id"      />
		<result property="jobName"        column="jobName"        />
		<result property="jobGroup"       column="jobGroup"       />
		<result property="methodName"     column="methodName"     />
		<result property="methodParams"   column="methodParams"   />
		<result property="jobMessage"     column="jobMessage"     />
		<result property="status"         column="status"          />
		<result property="exceptionInfo"  column="exceptionInfo"  />
		<result property="createTime"     column="createTime"     />
	</resultMap>
	
	<sql id="selectJobLogVo">
        select id, jobName, jobGroup, methodName, methodParams, jobMessage, status, exceptionInfo, createTime  from sys_job_log
    </sql>
	
	<select id="selectJobLogList" parameterType="com.huaheng.pc.monitor.job.domain.JobLog" resultMap="JobLogResult">
		<include refid="selectJobLogVo"/>
		<where>
			<if test="jobName != null and jobName != ''">
				AND jobName like concat('%', #{jobName}, '%')
			</if>
			<if test="status != null and status != ''">
				AND status = #{status}
			</if>
			<if test="methodName != null and methodName != ''">
				AND methodName like concat('%', #{methodName}, '%')
			</if>
			<if test="params != null and params.beginTime != null"><!-- 开始时间检索 -->
				and date_format(createTime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
			</if>
			<if test="params != null and params.endTime != null"><!-- 结束时间检索 -->
				and date_format(createTime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
			</if>
		</where>
	</select>
	

	<select id="selectJobLogById" parameterType="Integer" resultMap="JobLogResult">
		<include refid="selectJobLogVo"/>
		where id = #{id}
	</select>
	
	<delete id="deleteJobLogById" parameterType="Integer">
 		delete from sys_job_log where id = #{id}
 	</delete>
 	
 	<delete id="deleteJobLogByIds" parameterType="String">
 		delete from sys_job_log where id in
 		<foreach collection="array" item="id" open="(" separator="," close=")">
 			#{id}
        </foreach> 
 	</delete>
 	
 	<insert id="insertJobLog" parameterType="com.huaheng.pc.monitor.job.domain.JobLog">
 		insert into sys_job_log(
 			<if test="id != null and id != 0">id,</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="methodParams != null and methodParams != ''">methodParams,</if>
 			<if test="jobMessage != null and jobMessage != ''">jobMessage,</if>
 			<if test="status != null and status != ''">status,</if>
 			<if test="exceptionInfo != null and exceptionInfo != ''">exceptionInfo,</if>
 			createTime
 		)values(
 			<if test="id != null and id != 0">#{id},</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="methodParams != null and methodParams != ''">#{methodParams},</if>
 			<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
 			<if test="status != null and status != ''">#{status},</if>
 			<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
 			sysdate()
 		)
	</insert>

	<update id="truncateTable" >
		truncate table sys_job_log
	</update>

</mapper>