<?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.pcloudkeyword.dao.impl.PcloudRobotMemoDaoImpl" >
  <resultMap id="BaseResultMap" type="PcloudRobotMemo" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="group_id" property="groupId" jdbcType="INTEGER" />
    <result column="context" property="context" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>

  </resultMap>
  <sql id="Base_Column_List" >
    id, group_id,context,create_time,update_time
  </sql>

  <insert id="insert" parameterType="PcloudRobotMemo" useGeneratedKeys="true" keyProperty="id">
    insert into pcloud_robot_memo (
    group_id,
    context

      )
    values (

      #{groupId,jdbcType=INTEGER},
    #{context,jdbcType=VARCHAR}


      )
  </insert>

  <delete id="deleteById" parameterType="long">
    delete from pcloud_robot_memo where id=#{memoId}
  </delete>

    <select id="getMemoListByGroupId" parameterType="map" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_robot_memo where group_id=#{groupId}
    </select>

  <select id="getMemoByContext" parameterType="map" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/>
    from pcloud_robot_memo where 1=1
    <if test="context !=null">
      and context like concat('%', #{context}, '%')
    </if>
  </select>

  <update id="updateById" parameterType="map">
    update pcloud_robot_memo set context=#{context}
    where id=#{id}
  </update>


</mapper>