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.TenantGameQuota;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;

/**
 * 租户游戏配额Controller
 *
 * @author shi
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/common/quota")
public class TenantGameQuotaController extends BaseController
{
    @Autowired
    private ITenantGameQuotaService tenantGameQuotaService;

    /**
     * 查询租户游戏配额列表
     */
    @PreAuthorize("@ss.hasPermi('common:quota:list')")
    @GetMapping("/list")
    public TableDataInfo list(TenantGameQuota tenantGameQuota)
    {
        startPage();
        List<TenantGameQuota> list = tenantGameQuotaService.selectTenantGameQuotaList(tenantGameQuota);
        return getDataTable(list);
    }

    /**
     * 导出租户游戏配额列表
     */
    @PreAuthorize("@ss.hasPermi('common:quota:export')")
    @Log(title = "租户游戏配额", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TenantGameQuota tenantGameQuota)
    {
        List<TenantGameQuota> list = tenantGameQuotaService.selectTenantGameQuotaList(tenantGameQuota);
        ExcelUtil<TenantGameQuota> util = new ExcelUtil<TenantGameQuota>(TenantGameQuota.class);
        util.exportExcel(response, list, "租户游戏配额数据");
    }

    /**
     * 获取租户游戏配额详细信息
     */
    @PreAuthorize("@ss.hasPermi('common:quota:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tenantGameQuotaService.selectTenantGameQuotaById(id));
    }

    /**
     * 新增租户游戏配额
     */
    @PreAuthorize("@ss.hasPermi('common:quota:add')")
    @Log(title = "租户游戏配额", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TenantGameQuota tenantGameQuota)
    {
        return toAjax(tenantGameQuotaService.insertTenantGameQuota(tenantGameQuota));
    }

    /**
     * 修改租户游戏配额
     */
    @PreAuthorize("@ss.hasPermi('common:quota:edit')")
    @Log(title = "租户游戏配额", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TenantGameQuota tenantGameQuota)
    {
        return toAjax(tenantGameQuotaService.updateTenantGameQuota(tenantGameQuota));
    }

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