<?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.ejweb.modules.workbench.dao.ReportNoticeMapper" >
  <resultMap id="BaseResultMap" type="com.ejweb.modules.workbench.entity.ReportNotice" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="report_id" property="reportId" jdbcType="VARCHAR" />
    <result column="title" property="title" jdbcType="VARCHAR" />
    <result column="send_time" property="sendTime" jdbcType="VARCHAR" />
    <result column="send_from_id" property="sendFromId" jdbcType="VARCHAR" />
    <result column="send_to_id" property="sendToId" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, report_id, title, send_time, send_from_id, send_to_id, status, create_by, create_date, update_by,
    update_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from ct_bbtc_report_notice
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from ct_bbtc_report_notice
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.ejweb.modules.workbench.entity.ReportNotice" >
    insert into ct_bbtc_report_notice (id, title, send_time,
      send_from_id, send_to_id, status, 
      create_by, create_date, update_by, 
      update_date)
    values (#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{sendTime,jdbcType=VARCHAR}, 
      #{sendFromId,jdbcType=VARCHAR}, #{sendToId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, 
      #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, 
      #{updateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.ejweb.modules.workbench.entity.ReportNotice" >
    insert into ct_bbtc_report_notice
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="title != null" >
        title,
      </if>
      <if test="sendTime != null" >
        send_time,
      </if>
      <if test="sendFromId != null" >
        send_from_id,
      </if>
      <if test="sendToId != null" >
        send_to_id,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="createBy != null" >
        create_by,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateBy != null" >
        update_by,
      </if>
      <if test="updateDate != null" >
        update_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="title != null" >
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="sendTime != null" >
        #{sendTime,jdbcType=VARCHAR},
      </if>
      <if test="sendFromId != null" >
        #{sendFromId,jdbcType=VARCHAR},
      </if>
      <if test="sendToId != null" >
        #{sendToId,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null" >
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ejweb.modules.workbench.entity.ReportNotice" >
    update ct_bbtc_report_notice
    <set >
      <if test="title != null" >
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="sendTime != null" >
        send_time = #{sendTime,jdbcType=VARCHAR},
      </if>
      <if test="sendFromId != null" >
        send_from_id = #{sendFromId,jdbcType=VARCHAR},
      </if>
      <if test="sendToId != null" >
        send_to_id = #{sendToId,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null" >
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ejweb.modules.workbench.entity.ReportNotice" >
    update ct_bbtc_report_notice
    set title = #{title,jdbcType=VARCHAR},
      send_time = #{sendTime,jdbcType=VARCHAR},
      send_from_id = #{sendFromId,jdbcType=VARCHAR},
      send_to_id = #{sendToId,jdbcType=VARCHAR},
      status = #{status,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_date = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="selectBySendToId" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM ct_bbtc_report_notice
    WHERE send_to_id = #{sendToId,jdbcType=VARCHAR}
    order by send_time desc
  </select>

  <select id="getMessageCount" resultType="Integer">
    SELECT
    count(*)
    FROM
    CT_BBTC_REPORT_NOTICE n
    WHERE
    n.SEND_TO_ID = #{sendToId,jdbcType=VARCHAR}
    AND n.STATUS = '0'
  </select>
</mapper>