PendingJobMapper.xml 2.52 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.monitor.mysql.mapper.PendingJobMapper" >
  <resultMap id="BaseResultMap" type="com.model.PendingJob" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="work_id" property="workId" jdbcType="VARCHAR" />
    <result column="title" property="title" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="handler" property="handler" jdbcType="VARCHAR" />
    <result column="handler_role" property="handlerRole" jdbcType="VARCHAR" />
    <result column="current_status" property="currentStatus" jdbcType="INTEGER" />
    <result column="createTime" property="createTime" jdbcType="VARCHAR" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, work_id, title,type,handler,handler_role,current_status,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
  </sql>


  <select id="selectCount"  resultType="java.lang.Integer">
    select
    count(1)
    from pending_job
    where
    handler = #{handler}
  </select>

  <select id="selectByUser"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pending_job
    where
    handler = #{user}
    and work_id = #{workid}
  </select>

  <select id="selectByid"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pending_job
    where
    id = #{id}
  </select>

  <select id="selectByPage"   resultMap="BaseResultMap">
    select
      <include refid="Base_Column_List" />
    from pending_job
    where
    handler = #{params.handler}
    order by id
    limit #{startIndex},#{pageSize}
  </select>

  <insert id="insert" parameterType="com.model.HandledJob" >
    insert into pending_job
    (work_id,
      title,
      type,
      handler_role,
      handler,
      current_status,
      create_time)
    values
    (#{workId,jdbcType=VARCHAR},
     #{title,jdbcType=VARCHAR},
     #{type,jdbcType=VARCHAR},
     #{handlerRole,jdbcType=VARCHAR},
     #{handler,jdbcType=VARCHAR},
     #{currentStatus,jdbcType=INTEGER},
     now())
  </insert>

  <delete id="delete">
    DELETE FROM  pending_job where work_id = #{id}
  </delete>

  <delete id="deleteById">
    DELETE FROM  pending_job where id = #{id}
  </delete>

  <select id="selectByWorkId"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pending_job
    where  work_id = #{workid}
  </select>

</mapper>