package com.fs.live.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.live.domain.LiveUserLotteryRecord;
import com.fs.live.service.ILiveUserLotteryRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 直播用户中奖记录Controller
 *
 * @author fs
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/live/liveUserLotteryRecord")
public class LiveUserLotteryRecordController extends BaseController
{
    @Autowired
    private ILiveUserLotteryRecordService liveUserLotteryRecordService;

    /**
     * 查询直播用户中奖记录列表
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveUserLotteryRecord liveUserLotteryRecord)
    {
        startPage();
        List<LiveUserLotteryRecord> list = liveUserLotteryRecordService.selectLiveUserLotteryRecordList(liveUserLotteryRecord);
        return getDataTable(list);
    }

    /**
     * 导出直播用户中奖记录列表
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:export')")
    @Log(title = "直播用户中奖记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveUserLotteryRecord liveUserLotteryRecord)
    {
        List<LiveUserLotteryRecord> list = liveUserLotteryRecordService.selectLiveUserLotteryRecordList(liveUserLotteryRecord);
        ExcelUtil<LiveUserLotteryRecord> util = new ExcelUtil<LiveUserLotteryRecord>(LiveUserLotteryRecord.class);
        return util.exportExcel(list, "直播用户中奖记录数据");
    }

    /**
     * 获取直播用户中奖记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveUserLotteryRecordService.selectLiveUserLotteryRecordById(id));
    }

    /**
     * 新增直播用户中奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:add')")
    @Log(title = "直播用户中奖记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
    {
        return toAjax(liveUserLotteryRecordService.insertLiveUserLotteryRecord(liveUserLotteryRecord));
    }

    /**
     * 修改直播用户中奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:edit')")
    @Log(title = "直播用户中奖记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
    {
        return toAjax(liveUserLotteryRecordService.updateLiveUserLotteryRecord(liveUserLotteryRecord));
    }

    /**
     * 删除直播用户中奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:remove')")
    @Log(title = "直播用户中奖记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveUserLotteryRecordService.deleteLiveUserLotteryRecordByIds(ids));
    }

    /**
     * 查询直播用户中奖记录列表
     */
//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
    @PostMapping("/info")
    public R info(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
    {
        return liveUserLotteryRecordService.selectRecordByLiveIdAndLotteryId(liveUserLotteryRecord);
    }
}
