package com.fs.company.controller.live;

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.LiveGift;
import com.fs.live.service.ILiveGiftService;
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-08
 */
@RestController
@RequestMapping("/live/gift")
public class LiveGiftController extends BaseController
{
    @Autowired
    private ILiveGiftService liveGiftService;

    /**
     * 查询直播间礼物配置列表
     */
    @PreAuthorize("@ss.hasPermi('live:gift:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveGift liveGift)
    {
        startPage();
        List<LiveGift> list = liveGiftService.selectLiveGiftList(liveGift);
        return getDataTable(list);
    }

    /**
     * 导出直播间礼物配置列表
     */
    @PreAuthorize("@ss.hasPermi('live:gift:export')")
    @Log(title = "直播间礼物配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveGift liveGift)
    {
        List<LiveGift> list = liveGiftService.selectLiveGiftList(liveGift);
        ExcelUtil<LiveGift> util = new ExcelUtil<LiveGift>(LiveGift.class);
        return util.exportExcel(list, "直播间礼物配置数据");
    }

    /**
     * 获取直播间礼物配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:gift:query')")
    @GetMapping(value = "/{giftId}")
    public AjaxResult getInfo(@PathVariable("giftId") Long giftId)
    {
        return AjaxResult.success(liveGiftService.selectLiveGiftByGiftId(giftId));
    }

    /**
     * 新增直播间礼物配置
     */
    @PreAuthorize("@ss.hasPermi('live:gift:add')")
    @Log(title = "直播间礼物配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveGift liveGift)
    {
        return toAjax(liveGiftService.insertLiveGift(liveGift));
    }

    /**
     * 修改直播间礼物配置
     */
    @PreAuthorize("@ss.hasPermi('live:gift:edit')")
    @Log(title = "直播间礼物配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveGift liveGift)
    {
        return toAjax(liveGiftService.updateLiveGift(liveGift));
    }

    /**
     * 删除直播间礼物配置
     */
    @PreAuthorize("@ss.hasPermi('live:gift:remove')")
    @Log(title = "直播间礼物配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{giftIds}")
    public AjaxResult remove(@PathVariable Long[] giftIds)
    {
        return toAjax(liveGiftService.deleteLiveGiftByGiftIds(giftIds));
    }
}
