123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using GxPress.Request.Menu;
- 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;
- }
- /// <summary>
- /// 添加权限菜单关联
- /// </summary>
- /// <param name="models"></param>
- /// <returns></returns>
- [HttpPost("add-role-menus")]
- public async Task<bool> InsertSystemRoleMenusAsync(SystemRoleMenusInRequest models)
- {
- return await roleService.InsertSystemRoleMenusAsync(models);
- }
- /// <summary>
- /// 添加权限
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- [HttpPost("add-role")]
- public async Task<bool> InsertSystemRoleAsync(Entity.SystemRole.SystemRole model)
- {
- return await roleService.InsertSystemRoleAsync(model);
- }
- /// <summary>
- /// 修改权限
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- [HttpPut("update-role")]
- public async Task<bool> UpdateSystemRoleAsync(Entity.SystemRole.SystemRole model)
- {
- return await roleService.UpdateSystemRoleAsync(model);
- }
- /// <summary>
- /// 删除权限
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("role")]
- public async Task<bool> DeleteSystemRoleAsync(int id)
- {
- return await roleService.DeleteSystemRoleAsync(id);
- }
- /// <summary>
- /// 添加菜单
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- [HttpPost("add-menu")]
- public async Task<bool> InsertMenusAsync([FromBody] List<MenuInRequest> model)
- {
- return await roleService.InsertMenusAsync(model);
- }
- /// <summary>
- /// 修改菜单
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- [HttpPut("update-menu")]
- public async Task<bool> UpdateMenusAsync(Entity.Menus.Menus model)
- {
- return await roleService.UpdateMenusAsync(model);
- }
- /// <summary>
- /// 删除菜单
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("delete-menu")]
- public async Task<bool> DeleteMenusAsync(int id)
- {
- return await roleService.DeleteMenusAsync(id);
- }
- /// <summary>
- /// 根据权限ID获取菜单
- /// </summary>
- /// <param name="roleId"></param>
- /// <returns></returns>
- [HttpGet("menus/{roid}")]
- public async Task<IEnumerable<Entity.Menus.Menus>> GetMenusAllAsync(int roleId)
- {
- //获取
- return await roleService.GetMenusAllAsync(roleId);
- }
- /// <summary>
- /// 获取所有菜单
- /// </summary>
- /// <returns></returns>
- [HttpGet("menus")]
- public async Task<IEnumerable<Entity.Menus.Menus>> GetMenusAllAsync()
- {
- return await roleService.GetMenusAllAsync();
- }
- }
- }
|