<?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.pcloud.book.cultivate.dao.impl.CultivateNotifyDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.cultivate.entity.CultivateNotify" >
    <id column="message_id" property="messageId" jdbcType="BIGINT" />
    <result column="message_type" property="messageType" jdbcType="INTEGER" />
    <result column="title" property="title" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="send_type" property="sendType" jdbcType="INTEGER" />
    <result column="agent_id" property="agentId" jdbcType="BIGINT" />
    <result column="show_home" property="showHome" jdbcType="TINYINT" />
    <result column="square_img" property="squareImg" jdbcType="VARCHAR" />
  </resultMap>

  <sql id="Base_Column_List" >
    message_id, message_type, title, create_time,update_time,send_type,agent_id, show_home,square_img
  </sql>

  <insert id="insert" parameterType="com.pcloud.book.cultivate.entity.CultivateNotify" useGeneratedKeys="true" keyProperty="messageId">
    insert into cultivate_notify
    (
      message_type,
      title,
      create_time,
      update_time,
      send_type,
      agent_id,
      show_home,
    square_img
      )
    values (
      #{messageType},
      #{title},
      NOW(),
      NOW(),
      #{sendType},
      #{agentId},
      #{showHome},
    #{squareImg}
      )
  </insert>

  <update id="update" parameterType="com.pcloud.book.cultivate.entity.CultivateNotify">
    update cultivate_notify
    <set>
      <if test="messageType != null">
        message_type = #{messageType},
      </if>
      <if test="title != null">
        title = #{title},
      </if>
      update_time=NOW()
    </set>
    where message_id = #{messageId}
  </update>

  <select id="getByIds" parameterType="map" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
      from  cultivate_notify
    where message_id in
    <foreach collection="ids" open="(" close=")" separator="," item="item">
      #{item}
    </foreach>
  </select>

  <select id="getById" resultMap="BaseResultMap" parameterType="Long">
    select <include refid="Base_Column_List"/> from cultivate_notify where message_id = #{messageId}
  </select>

</mapper>