WorkJobMapper.xml 1.92 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.WorkJobMapper" >
    <resultMap id="BaseResultMap" type="com.model.WorkJob" >
        <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="createTime" property="createTime" jdbcType="VARCHAR" />

    </resultMap>

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

    <select id="selectCount"  resultType="java.lang.Integer">
        select
        count(1)
        from work_job
    </select>

    <select id="selectByPage"   resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from work_job
        where 1=1
        <if test="params.id != null" >
           and work_id = #{params.id}
        </if>
        order by create_time desc
        limit #{startIndex},#{pageSize}
    </select>

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

    <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.model.WorkJob" >
        insert into work_job
        (
        title,
        type,
        create_time
        )
        values
        (#{title,jdbcType=VARCHAR},
        #{type,jdbcType=VARCHAR},
        now())
    </insert>

    <update id="update" parameterType="com.model.WorkJob">
        UPDATE work_job
        set
          work_id =  #{workId}
        where
          id = #{id,jdbcType=INTEGER}
    </update>

</mapper>