public override void PreInitialize()
        {
            Configuration.DefaultNameOrConnectionString = _appConfiguration.GetConnectionString(IEManageSystemConsts.ConnectionStringName);

            Configuration.Modules.AbpAspNetCore()
            .CreateControllersForAppServices(
                typeof(IEManageSystemApplicationModule).GetAssembly()
                )
            .ConfigureControllerModel(controllerModel =>
            {
                foreach (var action in controllerModel.Actions)
                {
                    foreach (var selector in action.Selectors)
                    {
                        if (selector.AttributeRouteModel == null)
                        {
                            //
                            selector.AttributeRouteModel = new AttributeRouteModel(
                                new RouteAttribute(
                                    IEUrlHelper.CreateUrl(controllerModel.ControllerName, action.ActionName)
                                    )
                                );
                        }
                    }
                }
            });
        }
Exemple #2
0
        public async Task <ActionResult <ApiResultDataModel> > GetApiScopeUrls([FromBody] GetApiScopeUrlsInput input)
        {
            Expression <Func <ApiSingle, object> >[] propertySelectors = new Expression <Func <ApiSingle, object> >[] {
                e => e.ApiSingleActions
            };
            var apiSingles = _apiSingleRepository.GetAllIncluding(propertySelectors).Where(e => e.ApiScopeId == input.Id).ToList();

            List <GetApiScopeUrlsUrl> urls = new List <GetApiScopeUrlsUrl>();

            apiSingles.ForEach(apiSingle => {
                apiSingle.ApiSingleActions.ToList().ForEach(action =>
                {
                    urls.Add(new GetApiScopeUrlsUrl()
                    {
                        Url        = IEUrlHelper.CreateUrl(apiSingle.Name, action.Name),
                        IsQueryUrl = action.IsQueryAction
                    });
                });
            });

            return(new ApiResultDataModel(true, new GetApiScopeUrlsOutput()
            {
                Urls = urls
            }));
        }
Exemple #3
0
        public override void PreInitialize()
        {
            Configuration.DefaultNameOrConnectionString = _appConfiguration.GetConnectionString(IEManageSystemConsts.ConnectionStringName);

            Configuration.Modules.AbpAspNetCore()
            .CreateControllersForAppServices(
                typeof(IEManageSystemApplicationModule).GetAssembly()
                )
            .ConfigureControllerModel(controllerModel =>
            {
                foreach (var action in controllerModel.Actions)
                {
                    foreach (var selector in action.Selectors)
                    {
                        if (selector.AttributeRouteModel == null)
                        {
                            // 为方法添加路由
                            selector.AttributeRouteModel = new AttributeRouteModel(
                                new RouteAttribute(
                                    IEUrlHelper.CreateUrl(controllerModel.ControllerName, action.ActionName)
                                    )
                                );
                        }
                    }

                    foreach (var attr in controllerModel.Attributes)
                    {
                        // 如果控制器有应用ApiAuthorization特性
                        if (attr.GetType() == typeof(ApiAuthorizationAttribute) ||
                            attr.GetType().IsSubclassOf(typeof(ApiAuthorizationAttribute)))
                        {
                            var apiAuthorizationAttribute = (ApiAuthorizationAttribute)attr;

                            // 添加授权过滤器
                            controllerModel.Filters.Add(new ApiAuthorizationFilter(apiAuthorizationAttribute.ApiScopeName));
                        }
                    }
                }
            });
        }