package com.ruoyi.brewery.controller;

import com.ruoyi.brewery.domain.WyBrewery;
import com.ruoyi.brewery.service.IWyBreweryService;
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.SecurityUtils;
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/breweryinfo")
public class BreweryController extends BreweryBaseController
{
    @Autowired
    private IWyBreweryService wyBreweryService;

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

    /**
     * 导出品牌方列表
     */
//    @ApiOperation("导出品牌方列表")
//    @PreAuthorize("@bss.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("获取品牌方详细信息")
    @PreAuthorize("@bss.hasPermi('brewery:brewery:query')")
    @GetMapping
    public AjaxResult getInfo()
    {
        final Long breweryId = SecurityUtils.getBreweryLoginUser().getBreweryId();
        return success(wyBreweryService.selectWyBreweryById(breweryId));
    }

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

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

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