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.LiveLotteryRegistration;
import com.fs.live.service.ILiveLotteryRegistrationService;
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/liveLotteryRegistration")
public class LiveLotteryRegistrationController extends BaseController
{
    @Autowired
    private ILiveLotteryRegistrationService liveLotteryRegistrationService;

    /**
     * 查询直播抽奖登记列表
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRegistration:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveLotteryRegistration liveLotteryRegistration)
    {
        startPage();
        List<LiveLotteryRegistration> list = liveLotteryRegistrationService.selectLiveLotteryRegistrationList(liveLotteryRegistration);
        return getDataTable(list);
    }

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

    /**
     * 获取直播抽奖登记详细信息
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRegistration:query')")
    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return AjaxResult.success(liveLotteryRegistrationService.selectLiveLotteryRegistrationByRegistrationId(registrationId));
    }

    /**
     * 新增直播抽奖登记
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRegistration:add')")
    @Log(title = "直播抽奖登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveLotteryRegistration liveLotteryRegistration)
    {
        return toAjax(liveLotteryRegistrationService.insertLiveLotteryRegistration(liveLotteryRegistration));
    }

    /**
     * 修改直播抽奖登记
     */
//    @PreAuthorize("@ss.hasPermi('live:liveLotteryRegistration:edit')")
    @Log(title = "直播抽奖登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveLotteryRegistration liveLotteryRegistration)
    {
        return toAjax(liveLotteryRegistrationService.updateLiveLotteryRegistration(liveLotteryRegistration));
    }

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