package com.fs.app.controller.live;

import com.fs.app.annotation.Login;
import com.fs.app.controller.AppBaseController;
import com.fs.app.facade.LiveFacadeService;
import com.fs.common.core.domain.R;
import com.fs.common.param.BaseQueryParam;
import com.fs.live.param.LotteryPO;
import com.fs.live.service.ILiveLotteryConfService;
import com.fs.live.vo.LiveUserLotteryRecordVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/live/liveLottery")
public class LiveLotteryController extends AppBaseController {

    @Autowired
    private ILiveLotteryConfService liveLotteryConfService;
    @Autowired
    private LiveFacadeService liveFacadeService;


/*    *//**
     * 参与抽奖
     * *//*
    @RequestMapping("/participate")
    public String participate(Long liveId, Long userId,Long lotteryId) {
        return null;
    }*/

    /**
     * 参与抽奖
     * */
    @Login
    @PostMapping("/claim")
    public R claim(@RequestBody LotteryPO lottery) {
/*        lottery.setUserId(Long.parseLong(getUserId()));
        return liveLotteryConfService.claimLotteryPacket(lottery);*/
        lottery.setUserId(Long.parseLong(getUserId()));
        return liveFacadeService.drawClaim(lottery);
    }

    /**
     * 查询抽奖信息
     * */
    @Login
    @PostMapping("/detail")
    public R detail(@RequestBody LotteryPO lottery) {
        return liveLotteryConfService.detail(lottery);
    }

    /**
     * 查询抽奖信息
     * */
    @Login
    @GetMapping("/myLottery")
    public R myLottery(BaseQueryParam  param) {
        PageHelper.startPage(param.getPage(), param.getPageSize());

        List<LiveUserLotteryRecordVo> list = liveLotteryConfService.myLottery(Long.parseLong(getUserId()));
        PageInfo<LiveUserLotteryRecordVo> listPageInfo=new PageInfo<>(list);
        return R.ok().put("data",listPageInfo);
    }

}
