Esempio n. 1
0
        public async Task SaveRolePermission(Guid roleId, [FromForm] List <AuthorizePermissionModel> models)
        {
            var role = await _roleRepository.GetByIdAsync(roleId);

            if (role == null)
            {
                throw new GirvsException("未找到对应的角色", StatusCodes.Status404NotFound);
            }

            var command = new SavePermissionCommand(
                roleId,
                PermissionAppliedObjectType.Role,
                PermissionValidateObjectType.FunctionMenu,
                models.Select(x => new ObjectPermission()
            {
                AppliedObjectID    = x.ServiceId,
                PermissionOpeation =
                    PermissionHelper.ConvertStringToPermission(x.Permissions.Select(x => x.Value).ToList())
            }).ToList());

            await _bus.SendCommand(command);

            if (_notifications.HasNotifications())
            {
                var errorMessage = _notifications.GetNotificationMessage();
                throw new GirvsException(StatusCodes.Status400BadRequest, errorMessage);
            }
        }
Esempio n. 2
0
 // POST api/<controller>
 public void Post([FromBody] SavePermissionCommand command)
 {
     _savePermissionCommandHandler.Handle(command);
 }