package thyyxxk.webserver.dao.his.singlepage;

import org.apache.ibatis.annotations.*;
import thyyxxk.webserver.entity.singlepage.lottery.LotteryResult;
import thyyxxk.webserver.entity.singlepage.lottery.LotteryUser;

import java.util.List;

@Mapper
public interface LotteryDao {

    @Select("select * from t_lottery_user where won=-1 ")
    List<LotteryUser> selectLotteryUsers();

    @Select("select top(1) * from t_lottery_user where won=-1 order by newid()")
    LotteryUser selectRandomLotteryUser();

    @Update("update t_lottery_user set won=#{lotteryCode},won_time=getdate() " +
            "where code_rs=#{userCodeRs}")
    int updateLotteryResult(LotteryResult result);

    @Select("select code_rs,name,won,won_time from t_lottery_user " +
            "where won in (${statement}) and won>-1 order by won_time")
    List<LotteryUser> selectWonUsers(String statement);
}
