package com.ruoyi.brewery.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.brewery.domain.WyBrewerySharePlan;
import com.ruoyi.brewery.service.IWyBrewerySharePlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 品牌方分享方案Controller
 * 
 * @author ruoyi
 * @date 2025-02-23
 */
@Api(tags = "品牌方分享方案管理")
@RestController
@RequestMapping("/brewery/brewerySharePlan")
public class WyBrewerySharePlanController extends BaseController
{
    @Autowired
    private IWyBrewerySharePlanService wyBrewerySharePlanService;

    /**
     * 查询品牌方分享方案列表
     */
    @ApiOperation(value = "查询品牌方分享方案列表", notes = "查询品牌方分享方案列表")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBrewerySharePlan wyBrewerySharePlan)
    {
        startPage();
        List<WyBrewerySharePlan> list = wyBrewerySharePlanService.selectWyBrewerySharePlanList(wyBrewerySharePlan);
        return getDataTable(list);
    }

    /**
     * 导出品牌方分享方案列表
     */
    @ApiOperation(value = "导出品牌方分享方案列表", notes = "导出品牌方分享方案列表")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:export')")
    @Log(title = "品牌方分享方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBrewerySharePlan wyBrewerySharePlan)
    {
        List<WyBrewerySharePlan> list = wyBrewerySharePlanService.selectWyBrewerySharePlanList(wyBrewerySharePlan);
        ExcelUtil<WyBrewerySharePlan> util = new ExcelUtil<WyBrewerySharePlan>(WyBrewerySharePlan.class);
        util.exportExcel(response, list, "品牌方分享方案数据");
    }

    /**
     * 获取品牌方分享方案详细信息
     */
    @ApiOperation(value = "获取品牌方分享方案详细信息", notes = "获取品牌方分享方案详细信息")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyBrewerySharePlanService.selectWyBrewerySharePlanById(id));
    }

    /**
     * 新增品牌方分享方案
     */
    @ApiOperation(value = "新增品牌方分享方案", notes = "新增品牌方分享方案")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:add')")
    @Log(title = "品牌方分享方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBrewerySharePlan wyBrewerySharePlan)
    {
        return toAjax(wyBrewerySharePlanService.insertWyBrewerySharePlan(wyBrewerySharePlan));
    }

    /**
     * 修改品牌方分享方案
     */
    @ApiOperation(value = "修改品牌方分享方案", notes = "修改品牌方分享方案")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:edit')")
    @Log(title = "品牌方分享方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBrewerySharePlan wyBrewerySharePlan)
    {
        return toAjax(wyBrewerySharePlanService.updateWyBrewerySharePlan(wyBrewerySharePlan));
    }

    /**
     * 删除品牌方分享方案
     */
    @ApiOperation(value = "删除品牌方分享方案", notes = "删除品牌方分享方案")
    @PreAuthorize("@bss.hasPermi('brewery:brewerySharePlan:remove')")
    @Log(title = "品牌方分享方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyBrewerySharePlanService.deleteWyBrewerySharePlanByIds(ids));
    }
}
