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

/**
 * 会员投注细目Controller
 *
 * @author shi
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/game/details")
public class GameBettingDetailsController extends BaseController
{
    @Autowired
    private IGameBettingDetailsService gameBettingDetailsService;

    /**
     * 查询会员投注细目列表
     */
    @PreAuthorize("@ss.hasPermi('game:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameBettingDetails gameBettingDetails)
    {
        startPage();
        List<GameBettingDetails> list = gameBettingDetailsService.selectGameBettingDetailsList(gameBettingDetails);
        return getDataTable(list);
    }

    /**
     * 导出会员投注细目列表
     */
    @PreAuthorize("@ss.hasPermi('game:details:export')")
    @Log(title = "会员投注细目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameBettingDetails gameBettingDetails)
    {
        List<GameBettingDetails> list = gameBettingDetailsService.selectGameBettingDetailsList(gameBettingDetails);
        ExcelUtil<GameBettingDetails> util = new ExcelUtil<GameBettingDetails>(GameBettingDetails.class);
        util.exportExcel(response, list, "会员投注细目数据");
    }

    /**
     * 获取会员投注细目详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameBettingDetailsService.selectGameBettingDetailsById(id));
    }

    /**
     * 新增会员投注细目
     */
    @PreAuthorize("@ss.hasPermi('game:details:add')")
    @Log(title = "会员投注细目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameBettingDetails gameBettingDetails)
    {
        return toAjax(gameBettingDetailsService.insertGameBettingDetails(gameBettingDetails));
    }

    /**
     * 修改会员投注细目
     */
    @PreAuthorize("@ss.hasPermi('game:details:edit')")
    @Log(title = "会员投注细目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameBettingDetails gameBettingDetails)
    {
        return toAjax(gameBettingDetailsService.updateGameBettingDetails(gameBettingDetails));
    }

    /**
     * 删除会员投注细目
     */
    @PreAuthorize("@ss.hasPermi('game:details:remove')")
    @Log(title = "会员投注细目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameBettingDetailsService.deleteGameBettingDetailsByIds(ids));
    }
}
