package com.game.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.game.common.core.domain.R;
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.game.common.annotation.Log;
import com.game.common.core.controller.BaseController;
import com.game.common.core.domain.AjaxResult;
import com.game.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.game.business.domain.LiveLive;
import com.game.business.service.ILiveLiveService;
import com.game.common.utils.poi.ExcelUtil;
import com.game.common.core.page.TableDataInfo;

/**
 * 直播管理Controller
 * 
 * @author game
 * @date 2024-08-30
 */
@RestController
@RequestMapping("/business/live")
@Api(value = "LiveLiveController", description = "直播管理接口", tags = {"直播管理"})
public class LiveLiveController extends BaseController
{
    @Autowired
    private ILiveLiveService liveLiveService;

    /**
     * 查询直播管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:live:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询直播管理列表", notes = "获取直播管理列表")
    public TableDataInfo<LiveLive> list(LiveLive liveLive)
    {
        startPage();
        List<LiveLive> list = liveLiveService.selectLiveLiveList(liveLive);
        return getDataTable(list);
    }

    /**
     * 导出直播管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:live:export')")
    @Log(title = "直播管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出直播管理列表", notes = "导出直播管理列表")
    public void export(HttpServletResponse response, LiveLive liveLive)
    {
        List<LiveLive> list = liveLiveService.selectLiveLiveList(liveLive);
        ExcelUtil<LiveLive> util = new ExcelUtil<LiveLive>(LiveLive.class);
        util.exportExcel(response, list, "直播管理数据");
    }

    /**
     * 获取直播管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:live:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取直播管理详细信息", notes = "获取直播管理详细信息")
    public R<LiveLive> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(liveLiveService.selectLiveLiveById(id));
    }

    /**
     * 新增直播管理
     */
    @PreAuthorize("@ss.hasPermi('business:live:add')")
    @Log(title = "直播管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增直播管理", notes = "新增直播管理")
    @PostMapping
    public R add(@RequestBody LiveLive liveLive)
    {
        return R.ok(liveLiveService.insertLiveLive(liveLive));
    }

    /**
     * 修改直播管理
     */
    @PreAuthorize("@ss.hasPermi('business:live:edit')")
    @Log(title = "直播管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改直播管理", notes = "修改直播管理")
    @PutMapping
    public R edit(@RequestBody LiveLive liveLive)
    {
        return R.ok(liveLiveService.updateLiveLive(liveLive));
    }

    /**
     * 删除直播管理
     */
    @PreAuthorize("@ss.hasPermi('business:live:remove')")
    @Log(title = "直播管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除直播管理", notes = "删除直播管理")
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.ok(liveLiveService.deleteLiveLiveByIds(ids));
    }
}
