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.GameFreeRecord;
import com.ff.game.service.IGameFreeRecordService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;

/**
 * 免费赠送游戏记录Controller
 *
 * @author shi
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/game/record")
public class GameFreeRecordController extends BaseController
{
    @Autowired
    private IGameFreeRecordService gameFreeRecordService;

    /**
     * 查询免费赠送游戏记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameFreeRecord gameFreeRecord)
    {
        startPage();
        List<GameFreeRecord> list = gameFreeRecordService.selectGameFreeRecordList(gameFreeRecord);
        return getDataTable(list);
    }

    /**
     * 导出免费赠送游戏记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:record:export')")
    @Log(title = "免费赠送游戏记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameFreeRecord gameFreeRecord)
    {
        List<GameFreeRecord> list = gameFreeRecordService.selectGameFreeRecordList(gameFreeRecord);
        ExcelUtil<GameFreeRecord> util = new ExcelUtil<GameFreeRecord>(GameFreeRecord.class);
        util.exportExcel(response, list, "免费赠送游戏记录数据");
    }

    /**
     * 获取免费赠送游戏记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameFreeRecordService.selectGameFreeRecordById(id));
    }

    /**
     * 新增免费赠送游戏记录
     */
    @PreAuthorize("@ss.hasPermi('game:record:add')")
    @Log(title = "免费赠送游戏记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameFreeRecord gameFreeRecord)
    {
        return toAjax(gameFreeRecordService.insertGameFreeRecord(gameFreeRecord));
    }

    /**
     * 修改免费赠送游戏记录
     */
    @PreAuthorize("@ss.hasPermi('game:record:edit')")
    @Log(title = "免费赠送游戏记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameFreeRecord gameFreeRecord)
    {
        return toAjax(gameFreeRecordService.updateGameFreeRecord(gameFreeRecord));
    }

    /**
     * 删除免费赠送游戏记录
     */
    @PreAuthorize("@ss.hasPermi('game:record:remove')")
    @Log(title = "免费赠送游戏记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameFreeRecordService.deleteGameFreeRecordByIds(ids));
    }
}
