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

/**
 * 会员金额转移记录Controller
 *
 * @author shi
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/game/money")
public class GameExchangeMoneyController extends BaseController
{
    @Autowired
    private IGameExchangeMoneyService gameExchangeMoneyService;

    /**
     * 查询会员金额转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameExchangeMoney gameExchangeMoney)
    {
        startPage();
        List<GameExchangeMoney> list = gameExchangeMoneyService.selectGameExchangeMoneyList(gameExchangeMoney);
        return getDataTable(list);
    }

    /**
     * 导出会员金额转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:money:export')")
    @Log(title = "会员金额转移记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameExchangeMoney gameExchangeMoney)
    {
        List<GameExchangeMoney> list = gameExchangeMoneyService.selectGameExchangeMoneyList(gameExchangeMoney);
        ExcelUtil<GameExchangeMoney> util = new ExcelUtil<GameExchangeMoney>(GameExchangeMoney.class);
        util.exportExcel(response, list, "会员金额转移记录数据");
    }

    /**
     * 获取会员金额转移记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:money:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameExchangeMoneyService.selectGameExchangeMoneyById(id));
    }

    /**
     * 新增会员金额转移记录
     */
    @PreAuthorize("@ss.hasPermi('game:money:add')")
    @Log(title = "会员金额转移记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameExchangeMoney gameExchangeMoney)
    {
        return toAjax(gameExchangeMoneyService.insertGameExchangeMoney(gameExchangeMoney));
    }

    /**
     * 修改会员金额转移记录
     */
    @PreAuthorize("@ss.hasPermi('game:money:edit')")
    @Log(title = "会员金额转移记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameExchangeMoney gameExchangeMoney)
    {
        return toAjax(gameExchangeMoneyService.updateGameExchangeMoney(gameExchangeMoney));
    }

    /**
     * 删除会员金额转移记录
     */
    @PreAuthorize("@ss.hasPermi('game:money:remove')")
    @Log(title = "会员金额转移记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameExchangeMoneyService.deleteGameExchangeMoneyByIds(ids));
    }
}
