/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ifish.mapper;

import com.ifish.bean.Tbl_Push_List;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

/**
 *
 * @author Administrator
 */
public interface Tbl_Push_List_Mapper {

    /**
     * 分页获取用户推送消息
     *
     * @param userId
     * @param pushType
     * @param pageSize
     * @param firstResult
     * @return
     */
    @SelectProvider(type = Tbl_Push_List_MapperSql.class, method = "getPushList")
    List<Tbl_Push_List> getPushList(@Param("userid") Integer userId, @Param("pushtype") String pushType, @Param("pagesize") Integer pageSize, @Param("first") Integer firstResult);

    /**
     * 根据ID查询推送消息对象
     *
     * @param pushId
     * @return
     */
    @Select("SELECT push_id,user_id,device_id,show_name,phone_type,push_type,push_title,push_context,create_time,push_link,jpush_status,google_status FROM TBL_PUSH_LIST WHERE push_id = #{pushid}")
    Tbl_Push_List getPush_ListById(@Param("pushid") Integer pushId);

    /**
     * 根据ID删除推送消息
     *
     * @param pushId
     * @return
     */
    @Delete("DELETE FROM TBL_PUSH_LIST WHERE push_id = #{id}")
    Integer deletePushListById(@Param("id") Integer pushId);

    /**
     * 分页获取用户推送消息
     *
     * @param userId
     * @param pushType
     * @param pageSize
     * @param firstResult
     * @return
     */
    @Select("SELECT COUNT(1) FROM TBL_PUSH_LIST WHERE user_id = #{userid} AND push_type = #{pushtype} LIMIT ${first},${pagesize}")
    Integer getPushListCount(@Param("userid") Integer userId, @Param("pushtype") String pushType, @Param("pagesize") Integer pageSize, @Param("first") Integer firstResult);

}
