Esempio n. 1
0
 public static void InitQueryDto(ActionExecutingContext context)
 {
     foreach (var argument in context.ActionArguments)
     {
         if (argument.Value.GetType().BaseType == typeof(PageQueryDto))
         {
             var queryDto = argument.Value as PageQueryDto;
             queryDto.UserId = UserCliamUtil.GetUserId(context.HttpContext).ToInt32().GetValueOrDefault();
             queryDto.MemId  = UserCliamUtil.GetMemId(context.HttpContext).ToInt32().GetValueOrDefault();
         }
     }
 }
        public static void InitCurrentLoginUser(ActionExecutingContext context)
        {
            var userId     = UserCliamUtil.GetUserId(context.HttpContext);
            var actionName = context.ActionDescriptor.DisplayName;

            if (userId == "0")
            {
                return;
            }

            var authorizationConfig = context.HttpContext.RequestServices.GetService(typeof(IOptions <AuthorizationConfig>)) as IOptions <AuthorizationConfig>;
            var permiisionApiUrl    = authorizationConfig.Value.PermissinoApiUrl;

            var commandExecutorContainer = context.HttpContext.RequestServices.GetService <ICommandExecutorContainer>();
            var currentUser = UserInfoUtil.GetUserInfo(userId, permiisionApiUrl, context.HttpContext);

            commandExecutorContainer.CommandContext.CurrentUser = currentUser;
        }