package com.sqx.modules.discSpinning.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Api(value = "大转盘抽奖记录", tags = {"大转盘抽奖记录"})
@RequestMapping(value = "/app/discSpinningRecord")
public class DiscSpinningRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private DiscSpinningRecordService discSpinningRecordService;

    @GetMapping("/{id}")
    @ApiOperation("通过Id查询详情")
    public Result selectOne(@PathVariable Integer id) {
        return Result.success().put("data", discSpinningRecordService.getById(id));
    }

    @Login
    @GetMapping("/selectDiscSpinningRecord")
    @ApiOperation("查询大转盘抽奖记录")
    public Result selectDiscSpinningRecord(Integer page, Integer limit,@RequestAttribute("userId") Long userId) {
        return Result.success().put("data", discSpinningRecordService.page(new Page<>(page, limit), new QueryWrapper<DiscSpinningRecord>().eq("user_id",userId).orderByDesc("create_time")));
    }
}

