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.LiveUserRedRecord;
import com.fs.live.service.ILiveUserRedRecordService;
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/liveUserRedRecord")
public class LiveUserRedRecordController extends BaseController
{
    @Autowired
    private ILiveUserRedRecordService liveUserRedRecordService;

    /**
     * 查询直播用户红包记录列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveUserRedRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveUserRedRecord liveUserRedRecord)
    {
        startPage();
        List<LiveUserRedRecord> list = liveUserRedRecordService.selectLiveUserRedRecordList(liveUserRedRecord);
        return getDataTable(list);
    }

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

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

    /**
     * 新增直播用户红包记录
     */
    @PreAuthorize("@ss.hasPermi('live:liveUserRedRecord:add')")
    @Log(title = "直播用户红包记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveUserRedRecord liveUserRedRecord)
    {
        return toAjax(liveUserRedRecordService.insertLiveUserRedRecord(liveUserRedRecord));
    }

    /**
     * 修改直播用户红包记录
     */
    @PreAuthorize("@ss.hasPermi('live:liveUserRedRecord:edit')")
    @Log(title = "直播用户红包记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveUserRedRecord liveUserRedRecord)
    {
        return toAjax(liveUserRedRecordService.updateLiveUserRedRecord(liveUserRedRecord));
    }

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