package com.itheima.dao;

import com.itheima.domain.MoneyLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*****
 * @Author: http://www.itheima.com
 * @Description: com.itheima.dao.MoneyLogDao
 ****/
@Mapper
public interface MoneyLogDao {

    /***
     * 用户抢红包记录
     * @param username
     * @return
     */
    @Select("SELECT * FROM money_log WHERE username=#{username} ORDER BY createtime DESC LIMIT 20")
    List<MoneyLog> list(String username);

    /***
     * 添加红包
     * @param moneyLog
     * @return
     */
    @Insert("INSERT INTO money_log(id,money,createtime,username) VALUES(#{id},#{money},#{createtime},#{username})")
    int add(MoneyLog moneyLog);

    /***
     * 查询前100名抢到红包信息
     * @return
     */
    @Select("SELECT * FROM money_log ORDER BY money DESC LIMIT 100")
    List<MoneyLog> top();
}
