using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Request.Role; 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(Entity.SystemRole.SystemRole model) { return await roleService.InsertSystemRoleAsync(model); } /// /// 修改权限 /// /// /// [HttpPut("update-role")] public async Task UpdateSystemRoleAsync(Entity.SystemRole.SystemRole model) { return await roleService.UpdateSystemRoleAsync(model); } /// /// 删除权限 /// /// /// [HttpDelete("role")] 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(); } } }