JobMapper.xml 5.28 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.JobMapper">

    <resultMap type="com.huaheng.pc.monitor.job.domain.Job" id="JobResult">
        <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="cronExpression" column="cronExpression"/>
        <result property="misfirePolicy" column="misfirePolicy"/>
        <result property="status" column="status"/>
        <result property="createBy" column="createBy"/>
        <result property="createTime" column="createTime"/>
        <result property="updateBy" column="updateBy"/>
        <result property="updateTime" column="updateTime"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectJobVo">
        select id,
               jobName,
               jobGroup,
               methodName,
               methodParams,
               cronExpression,
               misfirePolicy,
               status,
               createBy,
               createTime,
               remark
        from sys_job
    </sql>

    <!--<update id="updateJobStatus">-->

    <!--</update>-->

    <select id="selectJobList" resultMap="JobResult">
        <include refid="selectJobVo"/>
        <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>
        </where>
    </select>

    <select id="selectJobAll" resultMap="JobResult">
        <include refid="selectJobVo"/>
    </select>

    <select id="selectJobById" resultMap="JobResult">
        <include refid="selectJobVo"/>
        where id = #{id}
    </select>

    <delete id="deleteJobById">
        delete
        from sys_job
        where id = #{id}
    </delete>

    <delete id="deleteJobByIds">
        delete from sys_job where id in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateJob">
        update sys_job
        <set>
            <if test="jobName != null and jobName != ''">jobName = #{jobName},</if>
            <if test="jobGroup != null and jobGroup != ''">jobGroup = #{jobGroup},</if>
            <if test="methodName != null and methodName != ''">methodName = #{methodName},</if>
            <if test="methodParams != null and methodParams != ''">methodParams = #{methodParams},</if>
            <if test="cronExpression != null and cronExpression != ''">cronExpression = #{cronExpression},</if>
            <if test="misfirePolicy != null and misfirePolicy != ''">misfirePolicy = #{misfirePolicy},</if>
            <if test="status !=null">status = #{status},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            <if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
            updateTime = sysdate()
        </set>
        where id = #{id}
    </update>

    <insert id="insertJob" useGeneratedKeys="true" keyProperty="id">
        insert into sys_job(
        <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="cronExpression != null and cronExpression != ''">cronExpression,</if>
        <if test="misfirePolicy != null and misfirePolicy != ''">misfirePolicy,</if>
        <if test="status != null and status != ''">status,</if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="createBy != null and createBy != ''">createBy,</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="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
        <if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
        <if test="status != null and status != ''">#{status},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        sysdate()
        )
    </insert>


    <update id="updateJobStatus">
        update sys_job
        <set>
            status = #{status},
            updateBy = #{updateBy}
        </set>
        where methodName = #{methodName}
    </update>

</mapper>