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.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.live.domain.LiveLotteryRecord;
import com.fs.live.service.ILiveLotteryRecordService;
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/liveLotteryRecord")
public class LiveLotteryRecordController extends BaseController
{
    @Autowired
    private ILiveLotteryRecordService liveLotteryRecordService;

    /**
     * 查询直播抽奖记录列表
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveLotteryRecord liveLotteryRecord)
    {
        startPage();
        List<LiveLotteryRecord> list = liveLotteryRecordService.selectLiveLotteryRecordList(liveLotteryRecord);
        return getDataTable(list);
    }

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

    /**
     * 获取直播抽奖记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRecord:query')")
    @GetMapping(value = "/{lotteryId}")
    public AjaxResult getInfo(@PathVariable("lotteryId") Long lotteryId)
    {
        return AjaxResult.success(liveLotteryRecordService.selectLiveLotteryRecordByLotteryId(lotteryId));
    }

    /**
     * 新增直播抽奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRecord:add')")
    @Log(title = "直播抽奖记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveLotteryRecord liveLotteryRecord)
    {
        return toAjax(liveLotteryRecordService.insertLiveLotteryRecord(liveLotteryRecord));
    }

    /**
     * 修改直播抽奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRecord:edit')")
    @Log(title = "直播抽奖记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveLotteryRecord liveLotteryRecord)
    {
        return toAjax(liveLotteryRecordService.updateLiveLotteryRecord(liveLotteryRecord));
    }

    /**
     * 删除直播抽奖记录
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRecord:remove')")
    @Log(title = "直播抽奖记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lotteryIds}")
    public AjaxResult remove(@PathVariable Long[] lotteryIds)
    {
        return toAjax(liveLotteryRecordService.deleteLiveLotteryRecordByLotteryIds(lotteryIds));
    }
}
