package com.ruoyi.web.controller.bar;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.bar.domain.WyBarRole;
import com.ruoyi.bar.service.IWyBarRoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 角色信息Controller
 * 
 * @author ruoyi
 * @date 2025-01-04
 */
@RestController
@RequestMapping("/system/bar/barRole")
public class WyBarRoleController extends BaseController
{
    @Autowired
    private IWyBarRoleService wyBarRoleService;

    /**
     * 查询角色信息列表
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBarRole wyBarRole)
    {
        startPage();
        List<WyBarRole> list = wyBarRoleService.selectWyBarRoleList(wyBarRole);
        return getDataTable(list);
    }

    /**
     * 导出角色信息列表
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:export')")
    @Log(title = "角色信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBarRole wyBarRole)
    {
        List<WyBarRole> list = wyBarRoleService.selectWyBarRoleList(wyBarRole);
        ExcelUtil<WyBarRole> util = new ExcelUtil<WyBarRole>(WyBarRole.class);
        util.exportExcel(response, list, "角色信息数据");
    }

    /**
     * 获取角色信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:query')")
    @GetMapping(value = "/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId)
    {
        return success(wyBarRoleService.selectWyBarRoleByRoleId(roleId));
    }

    /**
     * 新增角色信息
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:add')")
    @Log(title = "角色信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBarRole wyBarRole)
    {
        return toAjax(wyBarRoleService.insertWyBarRole(wyBarRole));
    }

    /**
     * 修改角色信息
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:edit')")
    @Log(title = "角色信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBarRole wyBarRole)
    {
        return toAjax(wyBarRoleService.updateWyBarRole(wyBarRole));
    }

    /**
     * 删除角色信息
     */
    @PreAuthorize("@ss.hasPermi('bar:barRole:remove')")
    @Log(title = "角色信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roleIds}")
    public AjaxResult remove(@PathVariable Long[] roleIds)
    {
        return toAjax(wyBarRoleService.deleteWyBarRoleByRoleIds(roleIds));
    }
}
