package com.ruoyi.web.controller.brewery;

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.WyBrewery;
import com.ruoyi.brewery.service.IWyBreweryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 品牌方Controller
 * 
 * @author ruoyi
 * @date 2024-12-21
 */
@Api(tags = "品牌方管理")
@RestController
@RequestMapping("/system/brewery/brewery")
public class WyBreweryController extends BaseController
{
    @Autowired
    private IWyBreweryService wyBreweryService;

    /**
     * 查询品牌方列表
     */
    @ApiOperation(value = "查询品牌方列表", notes = "查询品牌方列表")
    @PreAuthorize("@ss.hasPermi('brewery:brewery:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBrewery wyBrewery)
    {
        startPage();
        List<WyBrewery> list = wyBreweryService.selectWyBreweryList(wyBrewery);
        return getDataTable(list);
    }

    /**
     * 导出品牌方列表
     */
    @ApiOperation(value = "导出品牌方列表", notes = "导出品牌方列表")
    @PreAuthorize("@ss.hasPermi('brewery:brewery:export')")
    @Log(title = "品牌方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBrewery wyBrewery)
    {
        List<WyBrewery> list = wyBreweryService.selectWyBreweryList(wyBrewery);
        ExcelUtil<WyBrewery> util = new ExcelUtil<WyBrewery>(WyBrewery.class);
        util.exportExcel(response, list, "品牌方数据");
    }

    /**
     * 获取品牌方详细信息
     */
    @ApiOperation(value = "获取品牌方详细信息", notes = "获取品牌方详细信息")
    @PreAuthorize("@ss.hasPermi('brewery:brewery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyBreweryService.selectWyBreweryById(id));
    }

    /**
     * 新增品牌方
     */
    @ApiOperation(value = "新增品牌方", notes = "新增品牌方")
    @PreAuthorize("@ss.hasPermi('brewery:brewery:add')")
    @Log(title = "品牌方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBrewery wyBrewery)
    {
        return toAjax(wyBreweryService.insertWyBrewery(wyBrewery));
    }

    /**
     * 修改品牌方
     */
    @ApiOperation(value = "修改品牌方", notes = "修改品牌方")
    @PreAuthorize("@ss.hasPermi('brewery:brewery:edit')")
    @Log(title = "品牌方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBrewery wyBrewery)
    {
        return toAjax(wyBreweryService.updateWyBrewery(wyBrewery));
    }

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