Ejemplo n.º 1
0
        public virtual async Task <Result <AccountInfoByLoginResponseDto> > Info()
        {
            //int uid = AuthContextService.CurrentUser.Id;
            if (AuthContextService.CurrentUser.Roles.Count() == 0)
            {
                return(Result <AccountInfoByLoginResponseDto> .ReFailure(ResultCodes.AccountNotExist));
            }
            var result = await IocManager.Instance.Resolve <AccountPermissionService>()
                         .GetPermissions(AuthContextService.CurrentUser.Roles);

            if (result.Account == null)
            {
                return(Result <AccountInfoByLoginResponseDto> .ReFailure(ResultCodes.AccountNotExist));
            }

            AccountInfoByLoginResponseDto responseDto = new AccountInfoByLoginResponseDto(result.Account);

            if (result.Permissions.Count == 0)
            {
                return(Result <AccountInfoByLoginResponseDto> .ReSuccess(responseDto));
            }

            //组装响应数据
            responseDto.SetMenus(result.Permissions);
            return(Result <AccountInfoByLoginResponseDto> .ReSuccess(responseDto));
        }
Ejemplo n.º 2
0
        public async Task <Result <AccountInfoByLoginResponseDto> > Info()
        {
            int uid    = this.User.UserId();
            var result = await this._serviceProvider.GetRequiredService <AccountPermissionService>()
                         .GetPermissions(uid);

            if (result.Account == null)
            {
                return(Result <AccountInfoByLoginResponseDto> .ReFailure(ResultCodes.AccountNotExist));
            }

            AccountInfoByLoginResponseDto responseDto = new AccountInfoByLoginResponseDto(result.Account);

            if (result.Permissions.Count == 0)
            {
                return(Result <AccountInfoByLoginResponseDto> .ReSuccess(responseDto));
            }

            //组装响应数据
            responseDto.SetMenus(result.Permissions);
            return(Result <AccountInfoByLoginResponseDto> .ReSuccess(responseDto));
        }