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.LiveUserFirstEntry;
import com.fs.live.service.ILiveUserFirstEntryService;
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-09-04
 */
@RestController
@RequestMapping("/live/entry")
public class LiveUserFirstEntryController extends BaseController
{
    @Autowired
    private ILiveUserFirstEntryService liveUserFirstEntryService;

    /**
     * 查询用户每日首次进入直播间记录列表
     */
    @PreAuthorize("@ss.hasPermi('live:entry:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveUserFirstEntry liveUserFirstEntry)
    {
        startPage();
        List<LiveUserFirstEntry> list = liveUserFirstEntryService.selectLiveUserFirstEntryList(liveUserFirstEntry);
        return getDataTable(list);
    }

    /**
     * 导出用户每日首次进入直播间记录列表
     */
    @PreAuthorize("@ss.hasPermi('live:entry:export')")
    @Log(title = "用户每日首次进入直播间记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveUserFirstEntry liveUserFirstEntry)
    {
        List<LiveUserFirstEntry> list = liveUserFirstEntryService.selectLiveUserFirstEntryList(liveUserFirstEntry);
        ExcelUtil<LiveUserFirstEntry> util = new ExcelUtil<LiveUserFirstEntry>(LiveUserFirstEntry.class);
        return util.exportExcel(list, "用户每日首次进入直播间记录数据");
    }

    /**
     * 获取用户每日首次进入直播间记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:entry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveUserFirstEntryService.selectLiveUserFirstEntryById(id));
    }

    /**
     * 新增用户每日首次进入直播间记录
     */
    @PreAuthorize("@ss.hasPermi('live:entry:add')")
    @Log(title = "用户每日首次进入直播间记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveUserFirstEntry liveUserFirstEntry)
    {
        return toAjax(liveUserFirstEntryService.insertLiveUserFirstEntry(liveUserFirstEntry));
    }

    /**
     * 修改用户每日首次进入直播间记录
     */
    @PreAuthorize("@ss.hasPermi('live:entry:edit')")
    @Log(title = "用户每日首次进入直播间记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveUserFirstEntry liveUserFirstEntry)
    {
        return toAjax(liveUserFirstEntryService.updateLiveUserFirstEntry(liveUserFirstEntry));
    }

    /**
     * 删除用户每日首次进入直播间记录
     */
    @PreAuthorize("@ss.hasPermi('live:entry:remove')")
    @Log(title = "用户每日首次进入直播间记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveUserFirstEntryService.deleteLiveUserFirstEntryByIds(ids));
    }
}
