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 com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.game.business.domain.AppGameClassify;
import com.game.business.service.IAppGameClassifyService;
import com.game.common.utils.poi.ExcelUtil;
import com.game.common.core.page.TableDataInfo;

/**
 * 游戏分类Controller
 * 
 * @author dos
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/business/classify")
@Api(value = "AppGameClassifyController", description = "游戏分类接口", tags = {"游戏分类"})
public class AppGameClassifyController extends BaseController
{
    @Autowired
    private IAppGameClassifyService appGameClassifyService;

    /**
     * 查询游戏分类列表
     */
    @PreAuthorize("@ss.hasPermi('business:classify:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询游戏分类列表", notes = "获取游戏分类列表")
    public TableDataInfo list(AppGameClassify appGameClassify)
    {
        startPage();
        List<AppGameClassify> list = appGameClassifyService.list();
        return getDataTable(list);
    }

    /**
     * 查询游戏分类列表
     */
    @GetMapping("/allList")
    @ApiOperation(value = "查询游戏分类列表", notes = "获取游戏分类列表")
    public R<List<AppGameClassify>> allList()
    {
        AppGameClassify appGameClassify1 = new AppGameClassify();
        appGameClassify1.setStatus(1L);
        List<AppGameClassify> list = appGameClassifyService.selectAppGameClassifyList(appGameClassify1);
        return R.ok(list);
    }

    /**
     * 导出游戏分类列表
     */
    @PreAuthorize("@ss.hasPermi('business:classify:export')")
    @Log(title = "游戏分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出游戏分类列表", notes = "导出游戏分类列表")
    public void export(HttpServletResponse response, AppGameClassify appGameClassify)
    {
        List<AppGameClassify> list = appGameClassifyService.selectAppGameClassifyList(appGameClassify);
        ExcelUtil<AppGameClassify> util = new ExcelUtil<AppGameClassify>(AppGameClassify.class);
        util.exportExcel(response, list, "游戏分类数据");
    }

    /**
     * 获取游戏分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:classify:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取游戏分类详细信息", notes = "获取游戏分类详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appGameClassifyService.selectAppGameClassifyById(id));
    }

    /**
     * 新增游戏分类
     */
    @PreAuthorize("@ss.hasPermi('business:classify:add')")
    @Log(title = "游戏分类", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增游戏分类", notes = "新增游戏分类")
    @PostMapping
    public AjaxResult add(@RequestBody AppGameClassify appGameClassify)
    {
        return toAjax(appGameClassifyService.insertAppGameClassify(appGameClassify));
    }

    /**
     * 修改游戏分类
     */
    @PreAuthorize("@ss.hasPermi('business:classify:edit')")
    @Log(title = "游戏分类", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改游戏分类", notes = "修改游戏分类")
    @PutMapping
    public AjaxResult edit(@RequestBody AppGameClassify appGameClassify)
    {
        return toAjax(appGameClassifyService.updateAppGameClassify(appGameClassify));
    }

    /**
     * 删除游戏分类
     */
    @PreAuthorize("@ss.hasPermi('business:classify:remove')")
    @Log(title = "游戏分类", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除游戏分类", notes = "删除游戏分类")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appGameClassifyService.deleteAppGameClassifyByIds(ids));
    }
}
