public async Task <AjaxResult> SetPermission([FromBody] UserSetPermissionDto dto)
        {
            OperationResult result1 = await _identityContract.SetUserRoles(dto.UserId, dto.RoleIds);

            string          msg     = $"设置角色:{result1.Message}<br/>";
            OperationResult result2 = await _securityManager.SetUserModules(dto.UserId, dto.ModuleIds);

            msg += $"模块设置:{result2.Message}";

            AjaxResultType type;

            if (result1.ResultType == OperationResultType.NoChanged && result2.ResultType == OperationResultType.NoChanged)
            {
                type = AjaxResultType.Info;
            }
            else if (new[] { result1.ResultType, result2.ResultType }.Contains(OperationResultType.Success))
            {
                type = AjaxResultType.Success;
            }
            else
            {
                type = AjaxResultType.Error;
            }

            return(new AjaxResult(msg, type));
        }
Esempio n. 2
0
        public async Task <AjaxResult> SetRoles(UserSetRoleDto dto)
        {
            OperationResult result = await _identityContract.SetUserRoles(dto.UserId, dto.RoleIds);

            return(result.ToAjaxResult());
        }