package com.ruoyi.brewery.controller;

import com.ruoyi.brewery.domain.WyBeerCoinPlan;
import com.ruoyi.brewery.service.IWyBeerCoinPlanService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 啤酒币方案Controller
 * 
 * @author ruoyi
 * @date 2024-12-21
 */
@Api(tags = "啤酒币方案")
@RestController
@RequestMapping("/brewery/plan")
public class BreweryWyBeerCoinPlanController extends BaseController
{
    @Autowired
    private IWyBeerCoinPlanService wyBeerCoinPlanService;

    /**
     * 查询啤酒币方案列表
     */
    @ApiOperation("查询啤酒币方案列表")
    @PreAuthorize("@bss.hasPermi('brewery:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBeerCoinPlan wyBeerCoinPlan)
    {
        startPage();
        List<WyBeerCoinPlan> list = wyBeerCoinPlanService.selectWyBeerCoinPlanList(wyBeerCoinPlan);
        return getDataTable(list);
    }

    /**
     * 导出啤酒币方案列表
     */
    @ApiOperation("导出啤酒币方案列表")
    @PreAuthorize("@bss.hasPermi('brewery:plan:export')")
    @Log(title = "啤酒币方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBeerCoinPlan wyBeerCoinPlan)
    {
        List<WyBeerCoinPlan> list = wyBeerCoinPlanService.selectWyBeerCoinPlanList(wyBeerCoinPlan);
        ExcelUtil<WyBeerCoinPlan> util = new ExcelUtil<WyBeerCoinPlan>(WyBeerCoinPlan.class);
        util.exportExcel(response, list, "啤酒币方案数据");
    }

    /**
     * 获取啤酒币方案详细信息
     */
    @ApiOperation("获取啤酒币方案详细信息")
    @PreAuthorize("@bss.hasPermi('brewery:plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyBeerCoinPlanService.selectWyBeerCoinPlanById(id));
    }

    /**
     * 新增啤酒币方案
     */
    @ApiOperation("新增啤酒币方案")
    @PreAuthorize("@bss.hasPermi('brewery:plan:add')")
    @Log(title = "啤酒币方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBeerCoinPlan wyBeerCoinPlan)
    {
        return toAjax(wyBeerCoinPlanService.insertWyBeerCoinPlan(wyBeerCoinPlan));
    }

    /**
     * 修改啤酒币方案
     */
    @ApiOperation("修改啤酒币方案")
    @PreAuthorize("@bss.hasPermi('brewery:plan:edit')")
    @Log(title = "啤酒币方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBeerCoinPlan wyBeerCoinPlan)
    {
        return toAjax(wyBeerCoinPlanService.updateWyBeerCoinPlan(wyBeerCoinPlan));
    }

    /**
     * 删除啤酒币方案
     */
    @ApiOperation("删除啤酒币方案")
    @PreAuthorize("@bss.hasPermi('brewery:plan:remove')")
    @Log(title = "啤酒币方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyBeerCoinPlanService.deleteWyBeerCoinPlanByIds(ids));
    }
}
