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.checkerframework.checker.units.qual.A;
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.WyBreweryRole;
import com.ruoyi.brewery.service.IWyBreweryRoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 角色信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@Api(tags = "角色信息管理")
@RestController
@RequestMapping("/brewery/role")
public class WyBreweryRoleController extends BaseController
{
    @Autowired
    private IWyBreweryRoleService wyBreweryRoleService;

    /**
     * 查询角色信息列表
     */
    @ApiOperation(value = "查询角色信息列表", notes = "查询角色信息列表")
    @PreAuthorize("@bss.hasPermi('brewery:role:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBreweryRole wyBreweryRole)
    {
        startPage();
        List<WyBreweryRole> list = wyBreweryRoleService.selectWyBreweryRoleList(wyBreweryRole);
        return getDataTable(list);
    }

    /**
     * 导出角色信息列表
     */
    @ApiOperation(value = "导出角色信息列表", notes = "导出角色信息列表")
    @PreAuthorize("@bss.hasPermi('brewery:role:export')")
    @Log(title = "角色信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBreweryRole wyBreweryRole)
    {
        List<WyBreweryRole> list = wyBreweryRoleService.selectWyBreweryRoleList(wyBreweryRole);
        ExcelUtil<WyBreweryRole> util = new ExcelUtil<WyBreweryRole>(WyBreweryRole.class);
        util.exportExcel(response, list, "角色信息数据");
    }

    /**
     * 获取角色信息详细信息
     */
    @ApiOperation(value = "获取角色信息详细信息", notes = "获取角色信息详细信息")
    @PreAuthorize("@bss.hasPermi('brewery:role:query')")
    @GetMapping(value = "/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId)
    {
        return success(wyBreweryRoleService.selectWyBreweryRoleByRoleId(roleId));
    }

    /**
     * 新增角色信息
     */
    @ApiOperation(value = "新增角色信息", notes = "新增角色信息")
    @PreAuthorize("@bss.hasPermi('brewery:role:add')")
    @Log(title = "角色信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBreweryRole wyBreweryRole)
    {
        return toAjax(wyBreweryRoleService.insertWyBreweryRole(wyBreweryRole));
    }

    /**
     * 修改角色信息
     */
    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PreAuthorize("@bss.hasPermi('brewery:role:edit')")
    @Log(title = "角色信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBreweryRole wyBreweryRole)
    {
        return toAjax(wyBreweryRoleService.updateWyBreweryRole(wyBreweryRole));
    }

    /**
     * 删除角色信息
     */
    @ApiOperation(value = "删除角色信息", notes = "删除角色信息")
    @PreAuthorize("@bss.hasPermi('brewery:role:remove')")
    @Log(title = "角色信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roleIds}")
    public AjaxResult remove(@PathVariable Long[] roleIds)
    {
        return toAjax(wyBreweryRoleService.deleteWyBreweryRoleByRoleIds(roleIds));
    }
}
