package com.goafanti.common.dao;

import com.goafanti.common.model.MessageConsumer;
import com.goafanti.common.model.MessageFromSystem;
import com.goafanti.common.model.MessageFromSystemExample;
import com.goafanti.common.model.MessageProducer;
import com.goafanti.message.bo.IndexBo;
import com.goafanti.message.bo.MessageBo;

import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;

public interface MessageFromSystemMapper {
    /**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	long countByExample(MessageFromSystemExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int deleteByExample(MessageFromSystemExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int deleteByPrimaryKey(String id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int insert(MessageFromSystem record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int insertSelective(MessageFromSystem record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	List<MessageFromSystem> selectByExample(MessageFromSystemExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	MessageFromSystem selectByPrimaryKey(String id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int updateByExampleSelective(@Param("record") MessageFromSystem record,
			@Param("example") MessageFromSystemExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int updateByExample(@Param("record") MessageFromSystem record, @Param("example") MessageFromSystemExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int updateByPrimaryKeySelective(MessageFromSystem record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table message_from_system
	 * @mbg.generated  Mon Dec 25 18:55:04 CST 2017
	 */
	int updateByPrimaryKey(MessageFromSystem record);

	/**
     * 查询发？目？
     * @param sql
     * @return
     */
    String selectSendTarget(@Param("sql")String sql);

    /**
     * 
     * @param target
     * @return
     */
    int insertBatchMessage(List<MessageFromSystem> target);
    
    /**
     * 
     * @param target
     */
	int insertBatchProducer(List<MessageProducer> target);
	
	/**
	 * 
	 * @param target
	 * @return
	 */
	int insertBatchConsumer(List<MessageConsumer> target);
	
	/**
	 * 同步消息
	 * @param uid
	 * @return
	 */
	List<MessageBo> selectSyncMessage(@Param("uid")String uid);
	
	
	/**
	 * 查询极光账号是否存在
	 * @param uid
	 * @return
	 */
	String selectJPushAcc(@Param("uid")String uid);

	/**
	 * 绑定第三方账号
	 * @param uuid
	 * @param registrationId
	 * @param userName
	 * @param uid
	 * @return
	 */
	int updateJpushEasemobAccount(@Param("uuid")String uuid, @Param("registrationId")String registrationId, 
			@Param("easemobName")String easemobName, @Param("easemobPass")String easemobPass, @Param("uid")String uid,@Param("lastLoginTime")Date lastLoginTime);
	
	/**
	 * 把消息置为已读
	 * @param messageId
	 * @param uid
	 * @param readTime
	 * @return
	 */
	int updateMessageConsumer(@Param("messageId")String messageId, @Param("uid")String uid,@Param("readTime")Date readTime);

	/**
	 * 查询推荐目标
	 * @param sql
	 * @return
	 */
	List<MessageFromSystem> selectRecommendTarget(@Param("sql")String sql);

	/**
	 * APP首页消息
	 * @param id (user_id or admin_id)
	 * @return
	 */
	IndexBo selectMessageWithGroup(@Param("uid")String uid);

}