package com.fs.live.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.live.domain.LiveCouponIssue;
import com.fs.live.service.ILiveCouponIssueService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 优惠券领取Controller
 *
 * @author fs
 * @date 2025-09-30
 */
@RestController
@RequestMapping("/live/coupon/issue")
public class LiveCouponIssueController extends BaseController
{
    @Autowired
    private ILiveCouponIssueService liveCouponIssueService;

    /**
     * 查询优惠券领取列表
     */
    @PreAuthorize("@ss.hasPermi('live:issue:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveCouponIssue liveCouponIssue)
    {
        startPage();
        List<LiveCouponIssue> list = liveCouponIssueService.selectLiveCouponIssueList(liveCouponIssue);
        return getDataTable(list);
    }

    /**
     * 导出优惠券领取列表
     */
    @PreAuthorize("@ss.hasPermi('live:issue:export')")
    @Log(title = "优惠券领取", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveCouponIssue liveCouponIssue)
    {
        List<LiveCouponIssue> list = liveCouponIssueService.selectLiveCouponIssueList(liveCouponIssue);
        ExcelUtil<LiveCouponIssue> util = new ExcelUtil<LiveCouponIssue>(LiveCouponIssue.class);
        return util.exportExcel(list, "issue");
    }

    /**
     * 获取优惠券领取详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:issue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveCouponIssueService.selectLiveCouponIssueById(id));
    }

    /**
     * 新增优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('live:issue:add')")
    @Log(title = "优惠券领取", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveCouponIssue liveCouponIssue)
    {
        return toAjax(liveCouponIssueService.insertLiveCouponIssue(liveCouponIssue));
    }

    /**
     * 修改优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('live:issue:edit')")
    @Log(title = "优惠券领取", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveCouponIssue liveCouponIssue)
    {
        return toAjax(liveCouponIssueService.updateLiveCouponIssue(liveCouponIssue));
    }

    /**
     * 删除优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('live:issue:remove')")
    @Log(title = "优惠券领取", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveCouponIssueService.deleteLiveCouponIssueByIds(ids));
    }
}
