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.common.core.domain.entity.WyBreweryMenu;
import com.ruoyi.brewery.service.IWyBreweryMenuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 品牌方菜单权限Controller
 * 
 * @author ruoyi
 * @date 2024-12-22
 */
@Api(tags = "品牌方菜单权限")
@RestController
@RequestMapping("/brewery/menu")
public class BreweryMenuController extends BaseController
{
    @Autowired
    private IWyBreweryMenuService wyBreweryMenuService;

    /**
     * 查询品牌方菜单权限列表
     */
    @ApiOperation("查询品牌方菜单权限列表")
    @PreAuthorize("@bss.hasPermi('brewery:menu:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBreweryMenu wyBreweryMenu)
    {
        startPage();
        List<WyBreweryMenu> list = wyBreweryMenuService.selectWyBreweryMenuList(wyBreweryMenu);
        return getDataTable(list);
    }

    /**
     * 导出品牌方菜单权限列表
     */
    @ApiOperation("导出品牌方菜单权限列表")
    @PreAuthorize("@bss.hasPermi('brewery:menu:export')")
    @Log(title = "品牌方菜单权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBreweryMenu wyBreweryMenu)
    {
        List<WyBreweryMenu> list = wyBreweryMenuService.selectWyBreweryMenuList(wyBreweryMenu);
        ExcelUtil<WyBreweryMenu> util = new ExcelUtil<WyBreweryMenu>(WyBreweryMenu.class);
        util.exportExcel(response, list, "品牌方菜单权限数据");
    }

    /**
     * 获取品牌方菜单权限详细信息
     */
    @ApiOperation("获取品牌方菜单权限详细信息")
    @PreAuthorize("@bss.hasPermi('brewery:menu:query')")
    @GetMapping(value = "/{menuId}")
    public AjaxResult getInfo(@PathVariable("menuId") Long menuId)
    {
        return success(wyBreweryMenuService.selectWyBreweryMenuByMenuId(menuId));
    }

    /**
     * 新增品牌方菜单权限
     */
    @ApiOperation("新增品牌方菜单权限")
    @PreAuthorize("@bss.hasPermi('brewery:menu:add')")
    @Log(title = "品牌方菜单权限", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBreweryMenu wyBreweryMenu)
    {
        return toAjax(wyBreweryMenuService.insertWyBreweryMenu(wyBreweryMenu));
    }

    /**
     * 修改品牌方菜单权限
     */
    @ApiOperation("修改品牌方菜单权限")
    @PreAuthorize("@bss.hasPermi('brewery:menu:edit')")
    @Log(title = "品牌方菜单权限", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBreweryMenu wyBreweryMenu)
    {
        return toAjax(wyBreweryMenuService.updateWyBreweryMenu(wyBreweryMenu));
    }

    /**
     * 删除品牌方菜单权限
     */
    @ApiOperation("删除品牌方菜单权限")
    @PreAuthorize("@bss.hasPermi('brewery:menu:remove')")
    @Log(title = "品牌方菜单权限", businessType = BusinessType.DELETE)
	@DeleteMapping("/{menuIds}")
    public AjaxResult remove(@PathVariable Long[] menuIds)
    {
        return toAjax(wyBreweryMenuService.deleteWyBreweryMenuByMenuIds(menuIds));
    }
}
