using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using WIDESEA_DTO.System; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseController; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_Model.Models; using WIDESEAWCS_Model.Models.System; namespace WIDESEAWCS_WCSServer.Controllers.System { [Route("api/Sys_Role")] [ApiController] public class Sys_RoleController : ApiBaseController<ISys_RoleService, Sys_Role> { private readonly IHttpContextAccessor _httpContextAccessor; public Sys_RoleController(ISys_RoleService service, IHttpContextAccessor httpContextAccessor) : base(service) { _httpContextAccessor = httpContextAccessor; } [HttpPost, Route("getUserChildRoles")] public IActionResult GetUserChildRoles() { int roleId = App.User.RoleId; var data = Service.GetAllChildren(roleId); if (App.User.IsSuperAdmin) { return Json(WebResponseContent.Instance.OK(null, data)); } //䏿˜¯è¶…级管ç†ï¼Œå°†è‡ªå·±çš„角色查出æ¥ï¼Œåœ¨æ ‘å½¢èœå•ä¸Šä½œä¸ºæ ¹èŠ‚ç‚¹ var self = data.Where(x => x.Id == roleId) .Select(s => new RoleNodes() { Id = s.Id, ParentId = 0,//将自己的角色作为root节点 RoleName = s.RoleName }).ToList(); data.AddRange(self); return Json(WebResponseContent.Instance.OK(null, data)); } [HttpPost, Route("getCurrentTreePermission")] public IActionResult GetCurrentTreePermission() { return Json(Service.GetCurrentTreePermission()); } [HttpPost, Route("getUserTreePermission")] public IActionResult GetUserTreePermission(int roleId) { return Json(Service.GetUserTreePermission(roleId)); } [HttpPost, Route("savePermission")] public IActionResult SavePermission([FromBody] List<UserPermissionDTO> userPermissions, int roleId) { return Json(Service.SavePermission(userPermissions, roleId)); } } }