package com.ff.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ff.base.annotation.Log;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.BusinessType;
import com.ff.game.domain.GameSecretKey;
import com.ff.game.service.IGameSecretKeyService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;

/**
 * 游戏平台密钥管理Controller
 *
 * @author shi
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/game/key")
public class GameSecretKeyController extends BaseController
{
    @Autowired
    private IGameSecretKeyService gameSecretKeyService;

    /**
     * 查询游戏平台密钥管理列表
     */
    @PreAuthorize("@ss.hasPermi('game:key:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameSecretKey gameSecretKey)
    {
        startPage();
        List<GameSecretKey> list = gameSecretKeyService.selectGameSecretKeyList(gameSecretKey);
        return getDataTable(list);
    }

    /**
     * 导出游戏平台密钥管理列表
     */
    @PreAuthorize("@ss.hasPermi('game:key:export')")
    @Log(title = "游戏平台密钥管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameSecretKey gameSecretKey)
    {
        List<GameSecretKey> list = gameSecretKeyService.selectGameSecretKeyList(gameSecretKey);
        ExcelUtil<GameSecretKey> util = new ExcelUtil<GameSecretKey>(GameSecretKey.class);
        util.exportExcel(response, list, "游戏平台密钥管理数据");
    }

    /**
     * 获取游戏平台密钥管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:key:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameSecretKeyService.selectGameSecretKeyById(id));
    }

    /**
     * 新增游戏平台密钥管理
     */
    @PreAuthorize("@ss.hasPermi('game:key:add')")
    @Log(title = "游戏平台密钥管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameSecretKey gameSecretKey)
    {
        return toAjax(gameSecretKeyService.insertGameSecretKey(gameSecretKey));
    }

    /**
     * 修改游戏平台密钥管理
     */
    @PreAuthorize("@ss.hasPermi('game:key:edit')")
    @Log(title = "游戏平台密钥管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameSecretKey gameSecretKey)
    {
        return toAjax(gameSecretKeyService.updateGameSecretKey(gameSecretKey));
    }

    /**
     * 删除游戏平台密钥管理
     */
    @PreAuthorize("@ss.hasPermi('game:key:remove')")
    @Log(title = "游戏平台密钥管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameSecretKeyService.deleteGameSecretKeyByIds(ids));
    }
}
