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.LiveWatchUser;
import com.fs.live.service.ILiveWatchUserService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 直播间观看用户Controller
 * 
 * @author fs
 * @date 2025-01-18
 */
@RestController
@RequestMapping("/live/liveWatchUser")
public class LiveWatchUserController extends BaseController
{
    @Autowired
    private ILiveWatchUserService liveWatchUserService;

    /**
     * 查询直播间观看用户列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveWatchUser liveWatchUser)
    {
        startPage();
        List<LiveWatchUser> list = liveWatchUserService.selectLiveWatchUserList(liveWatchUser);
        return getDataTable(list);
    }

    /**
     * 导出直播间观看用户列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:export')")
    @Log(title = "直播间观看用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveWatchUser liveWatchUser)
    {
        List<LiveWatchUser> list = liveWatchUserService.selectLiveWatchUserList(liveWatchUser);
        ExcelUtil<LiveWatchUser> util = new ExcelUtil<LiveWatchUser>(LiveWatchUser.class);
        return util.exportExcel(list, "直播间观看用户数据");
    }

    /**
     * 获取直播间观看用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveWatchUserService.selectLiveWatchUserById(id));
    }

    /**
     * 新增直播间观看用户
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:add')")
    @Log(title = "直播间观看用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveWatchUser liveWatchUser)
    {
        return toAjax(liveWatchUserService.insertLiveWatchUser(liveWatchUser));
    }

    /**
     * 修改直播间观看用户
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:edit')")
    @Log(title = "直播间观看用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveWatchUser liveWatchUser)
    {
        return toAjax(liveWatchUserService.updateLiveWatchUser(liveWatchUser));
    }

    /**
     * 删除直播间观看用户
     */
    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:remove')")
    @Log(title = "直播间观看用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveWatchUserService.deleteLiveWatchUserByIds(ids));
    }
}
