public void Build(IPlatformModuleBuilder moduleBuilder)
            {
                moduleBuilder.ConfigDataProcessor <IPlatformEntity>(options => options.AddTask(typeof(PlatformEntityTask <>)));
                moduleBuilder.AddModel <Hcs.Platform.BaseModels.ModelConfig>();
                var getRoles = moduleBuilder.AddQueryFlowApi <IPlatformFunction>("functions", builder =>
                                                                                 builder.GetService <IUserPlatformRoleAccessor>()
                                                                                 .Pipe(x => x.Service.Roles.Select(s => new { Code = s.Code.Substring(0, s.Code.Length - s.PermissionCode.Length - 1), PermissionCode = s.PermissionCode }).Where(f => f.Code != "Everyone").GroupBy(g => g.Code).Select(s => new { Code = s.Key, Permissions = s.Select(p => p.PermissionCode) }))
                                                                                 .Ok());
                var getUser = moduleBuilder.AddGetFlowApi <long, PlatformUserInfo>("user", builder => builder.GetRequestKey <long>().GetData <long, BaseModels.PlatformUser>().Pipe(x => new PlatformUserInfo {
                    Id = x.Id, Name = x.Name
                }).Ok());

                moduleBuilder.Everyone.AddRole(getRoles);
                moduleBuilder.Everyone.AddRole(getUser);
            }
Exemple #2
0
        public void Build(IPlatformModuleBuilder moduleBuilder)
        {
            moduleBuilder.AddModel <Model.ModelConfig>();

            var customer = moduleBuilder.AddEntityApi <long, Model.Entities.Customer>(options =>
            {
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe1)));
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe2)));
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe3)));
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe4)));
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe5)));
                options.ConfigDeleteApi(x => x.OnDeleted(d => d.Pipe(Pipe6)));

                options.ConfigGetApi(x => x.OnGeted(y => y.QueryChildFor(z => z.Orders)));
                options.ConfigPostApi(x => x.OnCreated(y => y.SaveChildsFor(z => z.Orders)));
                options.ConfigPutApi(x => x.OnUpdated(y => y.SaveChildsFor(z => z.Orders)));
            });
            var space = "PlatformModule.Test";

            moduleBuilder.AddModuleFuncion($"{space}.{nameof(Model.Entities.Customer)}", options =>
            {
                options.AddStandardApiRoles(customer, o => o.View.AddOdataPermission <Model.Entities.Customer>(build => build.AllowExpand(x => x.CreatedByUser.Name)));
            });
        }