<?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.cab.dao.CabPushMapper" >
  <resultMap id="BaseResultMap" type="com.cab.model.CabPush" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="content" property="content" jdbcType="VARCHAR" />
    <result column="push_date" property="pushDate" jdbcType="TIMESTAMP" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="is_push" property="isPush" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="type_id" property="typeId" jdbcType="INTEGER" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, content, push_date, status, is_push, type, type_id, create_user, create_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from cab_pub_push
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cab_pub_push
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cab.model.CabPush" >
    insert into cab_pub_push (id, content, push_date,
    status, is_push, type,
    type_id, create_user, create_date
    )
    values (#{id,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{pushDate,jdbcType=TIMESTAMP},
    #{status,jdbcType=INTEGER}, #{isPush,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR},
    #{typeId,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}
    )
  </insert>
  <insert id="insertSelective" parameterType="com.cab.model.CabPush" >
    insert into cab_pub_push
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="content != null" >
        content,
      </if>
      <if test="pushDate != null" >
        push_date,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="isPush != null" >
        is_push,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="typeId != null" >
        type_id,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="content != null" >
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="pushDate != null" >
        #{pushDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null" >
        #{status,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        #{isPush,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null" >
        #{typeId,jdbcType=INTEGER},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cab.model.CabPush" >
    update cab_pub_push
    <set >
      <if test="content != null" >
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="pushDate != null" >
        push_date = #{pushDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        is_push = #{isPush,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=VARCHAR},
      </if>
      <if test="typeId != null" >
        type_id = #{typeId,jdbcType=INTEGER},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cab.model.CabPush" >
    update cab_pub_push
    set content = #{content,jdbcType=VARCHAR},
    push_date = #{pushDate,jdbcType=TIMESTAMP},
    status = #{status,jdbcType=INTEGER},
    is_push = #{isPush,jdbcType=INTEGER},
    type = #{type,jdbcType=VARCHAR},
    type_id = #{typeId,jdbcType=INTEGER},
    create_user = #{createUser,jdbcType=INTEGER},
    create_date = #{createDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!--自定义-->
  <update id="changeStatus" parameterType="java.lang.Integer" >
    update cab_pub_push
    set status = 1
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="getList" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select * from cab_pub_push
    where 1=1
    <if test="content != '' and  content != null" >
      and content like '%${content}%'
    </if>
    order by create_date desc
    limit #{start},#{limit}
  </select>
  <select id="getCount" resultType="java.lang.Long" parameterType="java.lang.Integer" >
    SELECT
    count(*)
    from cab_pub_push
    where 1=1
    <if test="content != '' and  content != null" >
      and content like '%${content}%'
    </if>
  </select>
</mapper>