package com.mercury.chat.user.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;

import com.mercury.chat.user.entity.Message;
import com.mercury.chat.user.entity.MessageTemplate;

public interface MessageMapper {
    
	@SelectProvider(type=MessageSqlProvider.class, method="countByExample")
    int countByExample(MessageTemplate example);

    @Insert({
        "insert into MESSAGE (ID, CHAT_FROM, ",
        "CHAT_TO, SHOP_ID, CREATE_TS, ",
        "MESSAGE)",
        "values (#{id,jdbcType=BIGINT}, #{chatFrom,jdbcType=VARCHAR}, ",
        "#{chatTo,jdbcType=VARCHAR}, #{shopId,jdbcType=BIGINT}, #{createTs,jdbcType=TIMESTAMP}, ",
        "#{message,jdbcType=CLOB})"
    })
    int insert(Message record);

    @InsertProvider(type=MessageSqlProvider.class, method="insertSelective")
    int insertSelective(Message record);

    @SelectProvider(type=MessageSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="CHAT_FROM", property="chatFrom", jdbcType=JdbcType.VARCHAR),
        @Result(column="CHAT_TO", property="chatTo", jdbcType=JdbcType.VARCHAR),
        @Result(column="SHOP_ID", property="shopId", jdbcType=JdbcType.BIGINT),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="MESSAGE", property="message", jdbcType=JdbcType.CLOB)
    })
    List<Message> selectByExampleWithBLOBs(MessageTemplate example);

    @SelectProvider(type=MessageSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="CHAT_FROM", property="chatFrom", jdbcType=JdbcType.VARCHAR),
        @Result(column="CHAT_TO", property="chatTo", jdbcType=JdbcType.VARCHAR),
        @Result(column="SHOP_ID", property="shopId", jdbcType=JdbcType.BIGINT),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Message> selectByExample(MessageTemplate example);


}
@@ -250,16 +250,62 @@
 sults;%0D%0A
+import org.apache.ibatis.annotations.Select;%0D%0A
 import o
@@ -342,32 +342,32 @@
 electProvider;%0D%0A
-
 import org.apach
@@ -665,389 +665,8 @@
 %0D%0A%0D%0A
-    @Insert(%7B%0D%0A        %22insert into MESSAGE (ID, CHAT_FROM, %22,%0D%0A        %22CHAT_TO, SHOP_ID, CREATE_TS, %22,%0D%0A        %22MESSAGE)%22,%0D%0A        %22values (#%7Bid,jdbcType=BIGINT%7D, #%7BchatFrom,jdbcType=VARCHAR%7D, %22,%0D%0A        %22#%7BchatTo,jdbcType=VARCHAR%7D, #%7BshopId,jdbcType=BIGINT%7D, #%7BcreateTs,jdbcType=TIMESTAMP%7D, %22,%0D%0A        %22#%7Bmessage,jdbcType=CLOB%7D)%22%0D%0A    %7D)%0D%0A    int insert(Message record);%0D%0A%0D%0A
     
@@ -1457,24 +1457,1339 @@
  example);%0D%0A
+    %0D%0A    @Select(%7B%0D%0A        %22select%22,%0D%0A        %22ID, CHAT_FROM, CHAT_TO, SHOP_ID, CREATE_TS, MESSAGE%22,%0D%0A        %22from MESSAGE%22,%0D%0A        %22where (CHAT_FROM = #%7BuserId,jdbcType=VARCHAR%7D or CHAT_TO = #%7BuserId,jdbcType=VARCHAR%7D)   and  SHOP_ID = #%7BshopId,jdbcType=BIGINT%7D%22,%0D%0A        %22limit #%7BbatchSize%7D offset #%7Boffset%7D%22%0D%0A    %7D)%0D%0A    @Results(%7B%0D%0A        @Result(column=%22ID%22, property=%22id%22, jdbcType=JdbcType.BIGINT, id=true),%0D%0A        @Result(column=%22CHAT_FROM%22, property=%22chatFrom%22, jdbcType=JdbcType.VARCHAR),%0D%0A        @Result(column=%22CHAT_TO%22, property=%22chatTo%22, jdbcType=JdbcType.VARCHAR),%0D%0A        @Result(column=%22SHOP_ID%22, property=%22shopId%22, jdbcType=JdbcType.BIGINT),%0D%0A        @Result(column=%22CREATE_TS%22, property=%22createTs%22, jdbcType=JdbcType.TIMESTAMP),%0D%0A        @Result(column=%22MESSAGE%22, property=%22message%22, jdbcType=JdbcType.CLOB)%0D%0A    %7D)%0D%0A    List%3CMessage%3E select(String userId, Long shopId, int offset, int batchSize);%0D%0A%09%0D%0A    @Insert(%7B%0D%0A        %22insert into MESSAGE (ID, CHAT_FROM, %22,%0D%0A        %22CHAT_TO, SHOP_ID, CREATE_TS, %22,%0D%0A        %22MESSAGE)%22,%0D%0A        %22values (#%7Bid,jdbcType=BIGINT%7D, #%7BchatFrom,jdbcType=VARCHAR%7D, %22,%0D%0A        %22#%7BchatTo,jdbcType=VARCHAR%7D, #%7BshopId,jdbcType=BIGINT%7D, #%7BcreateTs,jdbcType=TIMESTAMP%7D, %22,%0D%0A        %22#%7Bmessage,jdbcType=CLOB%7D)%22%0D%0A    %7D)%0D%0A    int insert(Message record);%0D%0A    
 %0D%0A    @Selec

add search message method to mybatis mapper