Exemple #1
0
        /// <summary>
        /// 通过角色ID获取角色信息
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        private async Task <ResponseBase> GetRoleView(long roleId)
        {
            var role = await _sysUserRoleBll.GetSysUserRole(roleId);

            if (role == null)
            {
                return(new ResponseBase().GetResponseError(StatusCode.UserRole30001, "角色不存在"));
            }
            var authorityCore = new AuthorityCore(role.AuthorityValue.ToBigInteger());
            var menu          = MenuLib.MenuConfigs.Select(p => new MenuView()
            {
                Id       = p.Id,
                Name     = p.Name,
                PerCode  = p.PerCode,
                Type     = p.Type,
                IsOwner  = authorityCore.Validation(p.Id),
                FatherId = p.FatherId
            }).ToList();
            var roleView = new GetUserRoleView()
            {
                Name    = role.Name,
                Menus   = ConvertToRoleMenu(menu),
                MyMenus = menu.Where(p => p.IsOwner).Select(p => p.Id).ToList()
            };

            return(ResponseBase.Success(roleView));
        }
Exemple #2
0
        /// <summary>
        /// 获取一个新角色信息
        /// </summary>
        /// <returns></returns>
        private ResponseBase GetAnNewRole()
        {
            var menu = MenuLib.MenuConfigs.Select(p => new MenuView()
            {
                Id       = p.Id,
                IsOwner  = false,
                Name     = p.Name,
                PerCode  = p.PerCode,
                Type     = p.Type,
                FatherId = p.FatherId
            }).ToList();
            var roleView = new GetUserRoleView()
            {
                Name  = string.Empty,
                Menus = ConvertToRoleMenu(menu)
            };

            return(ResponseBase.Success(roleView));
        }