using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Request.Menu;
using GxPress.Request.Role;
using GxPress.Result.SystemRole;
using GxPress.Service.Interface.Role;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GxPress.Api.AdminControllers
{
[Route("api/admin/system-role")]
[ApiController]
[Authorize]
public class AdminSystemRoleController : Controller
{
private readonly IRoleService roleService;
public AdminSystemRoleController(IRoleService roleService)
{
this.roleService = roleService;
}
///
/// 添加权限菜单关联
///
///
///
[HttpPost("add-role-menus")]
public async Task InsertSystemRoleMenusAsync(SystemRoleMenusInRequest models)
{
return await roleService.InsertSystemRoleMenusAsync(models);
}
///
/// 添加 角色和权限
///
///
///
[HttpPost("add-role")]
public async Task InsertSystemRoleAsync(RoleInRequest request)
{
return await roleService.InsertSystemRoleAsync(request);
}
///
/// 获取所有角色
///
///
[HttpGet("role")]
public async Task> GetSystemRoleAllAsync()
{
return await roleService.GetSystemRoleAllAsync();
}
///
/// 修改角色 权限
///
///
///
[HttpPut("update-role")]
public async Task UpdateSystemRoleAsync(RoleInRequest request)
{
return await roleService.UpdateSystemRoleAsync(request);
}
///
/// 删除权限
///
///
///
[HttpDelete("role/{id}")]
public async Task DeleteSystemRoleAsync(int id)
{
return await roleService.DeleteSystemRoleAsync(id);
}
///
/// 添加菜单
///
///
///
[HttpPost("add-menu")]
public async Task InsertMenusAsync([FromBody] List model)
{
return await roleService.InsertMenusAsync(model);
}
///
/// 修改菜单
///
///
///
[HttpPut("update-menu")]
public async Task UpdateMenusAsync(Entity.Menus.Menus model)
{
return await roleService.UpdateMenusAsync(model);
}
///
/// 删除菜单
///
///
///
[HttpDelete("delete-menu")]
public async Task DeleteMenusAsync(int id)
{
return await roleService.DeleteMenusAsync(id);
}
///
/// 根据权限ID获取菜单
///
///
///
[HttpGet("menus/{roid}")]
public async Task> GetMenusAllAsync(int roleId)
{
//获取
return await roleService.GetMenusAllAsync(roleId);
}
///
/// 获取所有菜单
///
///
[HttpGet("menus")]
public async Task> GetMenusAllAsync()
{
return await roleService.GetMenusAllAsync();
}
}
}