<?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.boot.security.server.dao.JobDao">

	<sql id="where">
		<where>
			<if test="params.description != null and params.description != ''">
				and t.description like concat('%', #{params.description}, '%')
			</if>
			<if test="params.status != null and params.status != ''">
				and t.status = #{params.status}
			</if>
		</where>
	</sql>

	<select id="count" resultType="int">
		select count(1) from t_job t
		<include refid="where" />
	</select>

	<select id="list" resultType="JobModel">
		select * from t_job t
		<include refid="where" />
		${params.orderBy}
        limit #{offset}, #{limit}
	</select>


	<update id="update">
		update t_job t
		<set>
			<if test="description != null">
				description = #{description},
			</if>
			<if test="cron != null">
				cron = #{cron},
			</if>
			<if test="springBeanName != null">
				springBeanName = #{springBeanName},
			</if>
			<if test="methodName != null">
				methodName = #{methodName},
			</if>
			<if test="status != null">
				status = #{status},
			</if>
			updateTime = now()
		</set>
		where t.jobName = #{jobName}
	</update>
</mapper>