package com.ff.common.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.common.domain.TenantGameQuotaFlow;
import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;

/**
 * 租户游戏额度流水Controller
 *
 * @author shi
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/common/flow")
public class TenantGameQuotaFlowController extends BaseController
{
    @Autowired
    private ITenantGameQuotaFlowService tenantGameQuotaFlowService;

    /**
     * 查询租户游戏额度流水列表
     */
    @PreAuthorize("@ss.hasPermi('common:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TenantGameQuotaFlow tenantGameQuotaFlow)
    {
        startPage();
        List<TenantGameQuotaFlow> list = tenantGameQuotaFlowService.selectTenantGameQuotaFlowList(tenantGameQuotaFlow);
        return getDataTable(list);
    }

    /**
     * 导出租户游戏额度流水列表
     */
    @PreAuthorize("@ss.hasPermi('common:flow:export')")
    @Log(title = "租户游戏额度流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TenantGameQuotaFlow tenantGameQuotaFlow)
    {
        List<TenantGameQuotaFlow> list = tenantGameQuotaFlowService.selectTenantGameQuotaFlowList(tenantGameQuotaFlow);
        ExcelUtil<TenantGameQuotaFlow> util = new ExcelUtil<TenantGameQuotaFlow>(TenantGameQuotaFlow.class);
        util.exportExcel(response, list, "租户游戏额度流水数据");
    }

    /**
     * 获取租户游戏额度流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('common:flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tenantGameQuotaFlowService.selectTenantGameQuotaFlowById(id));
    }

    /**
     * 新增租户游戏额度流水
     */
    @PreAuthorize("@ss.hasPermi('common:flow:add')")
    @Log(title = "租户游戏额度流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TenantGameQuotaFlow tenantGameQuotaFlow)
    {
        return toAjax(tenantGameQuotaFlowService.insertTenantGameQuotaFlow(tenantGameQuotaFlow));
    }

    /**
     * 修改租户游戏额度流水
     */
    @PreAuthorize("@ss.hasPermi('common:flow:edit')")
    @Log(title = "租户游戏额度流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TenantGameQuotaFlow tenantGameQuotaFlow)
    {
        return toAjax(tenantGameQuotaFlowService.updateTenantGameQuotaFlow(tenantGameQuotaFlow));
    }

    /**
     * 删除租户游戏额度流水
     */
    @PreAuthorize("@ss.hasPermi('common:flow:remove')")
    @Log(title = "租户游戏额度流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tenantGameQuotaFlowService.deleteTenantGameQuotaFlowByIds(ids));
    }
}
