Public Api to Custom Endpoints

This commit is contained in:
Sedat Öztürk 2025-07-27 21:57:19 +03:00
parent 7d8b56701c
commit 216b2a1ec9
12 changed files with 5461 additions and 186 deletions

View file

@ -20,7 +20,7 @@
- SQL Veritabanını Entity Class oluştur.
`dotnet ef dbcontext scaffold "Server=SERVERNAME;Database=DBNAME;User ID=USERNAME;Password=PASSWORD;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer --context MyDbContext --output-dir Models --data-annotations --force`
# Public Api
# Custom Endpoints
```
Token İsteği Örnek:

View file

@ -16,19 +16,19 @@ using Volo.Abp.Domain.Repositories;
using Volo.Abp.Tracing;
using Volo.Abp.Uow;
namespace Kurs.Platform.PublicApis;
namespace Kurs.Platform.CustomEndpoints;
[Authorize]
[Route("api/app/public-api")]
public class PublicApiAppService : PlatformAppService
[Route("api/app/custom-endpoint")]
public class CustomEndpointAppService : PlatformAppService
{
private readonly IRepository<PublicApi, Guid> repo;
private readonly IRepository<CustomEndpoint, Guid> repo;
private readonly IHttpContextAccessor httpContextAccessor;
private readonly IDataSourceManager dataSourceManager;
private readonly IDynamicDataManager dynamicDataManager;
public PublicApiAppService(
IRepository<PublicApi, Guid> repo,
public CustomEndpointAppService(
IRepository<CustomEndpoint, Guid> repo,
IHttpContextAccessor httpContextAccessor,
IDataSourceManager dataSourceManager,
IDynamicDataManager dynamicDataManager)
@ -40,14 +40,14 @@ public class PublicApiAppService : PlatformAppService
}
[HttpGet("{**path}")]
[Authorize(PlatformConsts.AppCodes.PublicApis.Get)]
[Authorize(PlatformConsts.AppCodes.CustomEndpoints.Get)]
public async Task<IActionResult> GetAsync()
{
return await Execute("GET");
}
[HttpPost("{**path}")]
[Authorize(PlatformConsts.AppCodes.PublicApis.Post)]
[Authorize(PlatformConsts.AppCodes.CustomEndpoints.Post)]
public async Task<IActionResult> PostAsync()
{
return await Execute("POST");
@ -64,14 +64,14 @@ public class PublicApiAppService : PlatformAppService
.Replace("/api/app/public-api", "")
.EnsureStartsWith('/')
.EnsureEndsWith('/');
Logger.LogInformation("PublicApi çağrısı. Kullanıcı:{user} Path:[{method}]{path}", CurrentUser.UserName, "GET", path);
Logger.LogInformation("Custom Endpoint çağrısı. Kullanıcı:{user} Path:[{method}]{path}", CurrentUser.UserName, "GET", path);
var api = await repo.FirstOrDefaultAsync(a => path.StartsWith(a.Url) && a.Method == method);
if (api is null)
{
Logger.LogInformation("PublicApi bulunamadı");
Logger.LogInformation("Custom Endpoint bulunamadı");
return new NotFoundResult();
}
Logger.LogInformation("PublicApi bulundu. {api}", api.Name);
Logger.LogInformation("Custom Endpoint bulundu. {api}", api.Name);
var canUse = api.Permissions.Any(a =>
(a.ResourceType == "User" && a.ResourceId == CurrentUser.UserName) ||
@ -79,7 +79,7 @@ public class PublicApiAppService : PlatformAppService
(a.ResourceType == "Global"));
if (!canUse)
{
Logger.LogWarning("PublicApi yetki yok");
Logger.LogWarning("Custom Endpoint yetki yok");
return new UnauthorizedResult();
}
@ -87,7 +87,7 @@ public class PublicApiAppService : PlatformAppService
Dictionary<string, object> param = [];
// Parametreler:
// 1- Statik
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.PublicApiConsts.ParameterTypes.Static))
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.CustomEndpointConsts.ParameterTypes.Static))
{
var value = GetDefaultValue(item.DefaultValue);
param.Add(item.Name, value);
@ -95,7 +95,7 @@ public class PublicApiAppService : PlatformAppService
// 2- Query
var queryParams = httpContextAccessor.HttpContext.Request.Query;
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.PublicApiConsts.ParameterTypes.Query))
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.CustomEndpointConsts.ParameterTypes.Query))
{
if (queryParams.TryGetValue(item.Name, out var value))
{
@ -115,7 +115,7 @@ public class PublicApiAppService : PlatformAppService
}
// 3- Path
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.PublicApiConsts.ParameterTypes.Path && !a.Path.IsNullOrWhiteSpace()))
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.CustomEndpointConsts.ParameterTypes.Path && !a.Path.IsNullOrWhiteSpace()))
{
var itemPath = item.Path.EnsureStartsWith('/').EnsureEndsWith('/');
var index = itemPath.IndexOf($"/:{item.Name}/");
@ -132,7 +132,7 @@ public class PublicApiAppService : PlatformAppService
if (method == "POST")
{
var body = await httpContextAccessor.HttpContext.Request.ReadFormAsync();
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.PublicApiConsts.ParameterTypes.Body))
foreach (var item in api.Parameters.Where(a => a.Type == PlatformConsts.CustomEndpointConsts.ParameterTypes.Body))
{
if (body.TryGetValue(item.Name, out var value))
{
@ -202,7 +202,7 @@ public class PublicApiAppService : PlatformAppService
}
}
//TODO: PublicApi rol, permission seed
//TODO: Custom Endpoint rol, permission seed
/*
Token İsteği Örnek:
POST /connect/token HTTP/1.1
@ -215,7 +215,7 @@ username=system%40sozsoft.com
&client_id=Platform_PublicApi
&scope=offline_access%20Platform
PublicApi Seed:
Custom Endpoint Seed:
select * from PLanguage WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName
INSERT INTO [dbo].[Orders]
([CustomerName]

View file

@ -6459,23 +6459,23 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
}
#endregion
#region Public Api
if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.PublicApi))
#region Custom Endpoint
if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.CustomEndpoint))
{
var listFormPublicApis = await _listFormRepository.InsertAsync(
var listFormCustomEndpoints = await _listFormRepository.InsertAsync(
new ListForm()
{
CultureName = LanguageCodes.En,
ListFormCode = ListFormCodes.Lists.PublicApi,
Name = AppCodes.PublicApis,
Title = AppCodes.PublicApis,
ListFormCode = ListFormCodes.Lists.CustomEndpoint,
Name = AppCodes.CustomEndpoints,
Title = AppCodes.CustomEndpoints,
DataSourceCode = SeedConsts.DataSources.DefaultCode,
IsTenant = false,
IsBranch = false,
IsOrganizationUnit = false,
Description = AppCodes.PublicApis,
Description = AppCodes.CustomEndpoints,
SelectCommandType = SelectCommandTypeEnum.Table,
SelectCommand = SelectCommandByTableName("PublicApi"),
SelectCommand = SelectCommandByTableName("CustomEndpoint"),
KeyFieldName = "Id",
KeyFieldDbSourceType = DbType.Guid,
DefaultFilter = "\"IsDeleted\" = 'false'",
@ -6511,19 +6511,19 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
ButtonPosition= UiCommandButtonPositionTypeEnum.Toolbar,
Hint = "Swagger",
Text = "Swagger",
AuthName=AppCodes.PublicApis,
AuthName=AppCodes.CustomEndpoints,
Url= swaggerRootUrl + "/swagger/index.html",
},
}),
PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
D = AppCodes.PublicApis + ".Delete",
E = AppCodes.PublicApis + ".Export",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
D = AppCodes.CustomEndpoints + ".Delete",
E = AppCodes.CustomEndpoints + ".Export",
}),
DeleteCommand = $"UPDATE \"{DbTablePrefix}PublicApi\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id",
DeleteCommand = $"UPDATE \"{DbTablePrefix}CustomEndpoint\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id",
DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] {
new() {
FieldName = "DeleterId",
@ -6553,7 +6553,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
{
Popup = new GridEditingPopupDto()
{
Title = "Public Api Form",
Title = "Custom Endpoint Form",
Width = 800,
Height = 500
},
@ -6591,10 +6591,10 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
}
);
#region Public Api Fields
#region Custom Endpoint Fields
await _listFormFieldRepository.InsertManyAsync([
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6607,9 +6607,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
IsDeleted = false,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6619,7 +6619,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6633,9 +6633,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6645,7 +6645,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6659,9 +6659,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6671,7 +6671,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6685,9 +6685,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6697,7 +6697,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6727,9 +6727,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
}),
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6739,7 +6739,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6753,9 +6753,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6771,7 +6771,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6785,9 +6785,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6797,7 +6797,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6811,9 +6811,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),
@ -6823,7 +6823,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
})
},
new() {
ListFormCode = listFormPublicApis.ListFormCode,
ListFormCode = listFormCustomEndpoints.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
@ -6837,9 +6837,9 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
AllowSearch = true,
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AppCodes.PublicApis + ".Create",
R = AppCodes.PublicApis,
U = AppCodes.PublicApis + ".Update",
C = AppCodes.CustomEndpoints + ".Create",
R = AppCodes.CustomEndpoints,
U = AppCodes.CustomEndpoints + ".Update",
E = true,
Deny = false
}),

View file

@ -1317,9 +1317,9 @@
},
{
"resourceName": "Platform",
"key": "App.PublicApis",
"en": "Public Apis",
"tr": "Genel Api'ler"
"key": "App.CustomEndpoints",
"en": "Custom Endpoints",
"tr": "Özel Uç Noktalar"
},
{
"resourceName": "Platform",
@ -6866,12 +6866,12 @@
},
{
"ParentCode": "App.Saas",
"Code": "App.PublicApis",
"DisplayName": "App.PublicApis",
"Code": "App.CustomEndpoints",
"DisplayName": "App.CustomEndpoints",
"Order": 9,
"Url": "/admin/list/list-publicapi",
"Url": "/admin/list/list-customendpoint",
"Icon": "FcMindMap",
"RequiredPermissionName": "App.PublicApis",
"RequiredPermissionName": "App.CustomEndpoints",
"IsDisabled": false
},
{
@ -7187,8 +7187,8 @@
"DisplayName": "App.BackgroundWorkers"
},
{
"Name": "App.PublicApis",
"DisplayName": "App.PublicApis"
"Name": "App.CustomEndpoints",
"DisplayName": "App.CustomEndpoints"
},
{
"Name": "App.Setting",
@ -7405,10 +7405,10 @@
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints",
"ParentName": null,
"DisplayName": "App.PublicApis",
"DisplayName": "App.CustomEndpoints",
"IsEnabled": true,
"MultiTenancySide": 2
},
@ -8277,49 +8277,49 @@
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Create",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Create",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Create",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Delete",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Delete",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Delete",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Export",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Export",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Export",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Get",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Get",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Get",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Post",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Post",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Post",
"IsEnabled": true,
"MultiTenancySide": 2
},
{
"GroupName": "App.PublicApis",
"Name": "App.PublicApis.Update",
"ParentName": "App.PublicApis",
"GroupName": "App.CustomEndpoints",
"Name": "App.CustomEndpoints.Update",
"ParentName": "App.CustomEndpoints",
"DisplayName": "Update",
"IsEnabled": true,
"MultiTenancySide": 2

View file

@ -289,9 +289,9 @@ public static class PlatformConsts
public const string Notification = Default + ".Notification";
}
public const string BackgroundWorkers = Prefix.App + ".BackgroundWorkers";
public static class PublicApis
public static class CustomEndpoints
{
public const string Default = Prefix.App + ".PublicApis";
public const string Default = Prefix.App + ".CustomEndpoints";
public const string Get = Default + ".Get";
public const string Post = Default + ".Post";
}
@ -342,7 +342,7 @@ public static class PlatformConsts
public const string NotificationRule = "list-notificationrule";
public const string Notification = "list-notification";
public const string IpRestriction = "list-iprestriction";
public const string PublicApi = "list-publicapi";
public const string CustomEndpoint = "list-customendpoint";
public const string PermissionGroup = "list-permissiongroup";
public const string GlobalSearch = "list-globalsearch";
public const string SecurityLog = "list-securitylog";
@ -1252,7 +1252,7 @@ public static class PlatformConsts
new SelectListItem { Value = LanguageCodes.Zh, Text = LanguageNames.Zh },
];
public static class PublicApiConsts
public static class CustomEndpointConsts
{
public static class ParameterTypes
{

View file

@ -347,7 +347,7 @@ public static class SeedConsts
public const string Notification = Default + ".Notification";
}
public const string BackgroundWorkers = Prefix.App + ".BackgroundWorkers";
public const string PublicApis = Prefix.App + ".PublicApis";
public const string CustomEndpoints = Prefix.App + ".CustomEndpoints";
public static class BlogManagement
{

View file

@ -7,7 +7,7 @@ using Volo.Abp.MultiTenancy;
namespace Kurs.Platform.Entities;
public class PublicApi : FullAuditedEntity<Guid>, IMultiTenant
public class CustomEndpoint : FullAuditedEntity<Guid>, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
@ -25,12 +25,12 @@ public class PublicApi : FullAuditedEntity<Guid>, IMultiTenant
public string PermissionsJson { get; set; }
[NotMapped]
public List<PublicApiParameter> Parameters
public List<CustomEndpointParameter> Parameters
{
get
{
if (!string.IsNullOrEmpty(ParametersJson))
return JsonSerializer.Deserialize<List<PublicApiParameter>>(ParametersJson);
return JsonSerializer.Deserialize<List<CustomEndpointParameter>>(ParametersJson);
return [];
}
@ -41,12 +41,12 @@ public class PublicApi : FullAuditedEntity<Guid>, IMultiTenant
}
[NotMapped]
public List<PublicApiPermission> Permissions
public List<CustomEndpointPermission> Permissions
{
get
{
if (!string.IsNullOrEmpty(PermissionsJson))
return JsonSerializer.Deserialize<List<PublicApiPermission>>(PermissionsJson);
return JsonSerializer.Deserialize<List<CustomEndpointPermission>>(PermissionsJson);
return [];
}
@ -57,7 +57,7 @@ public class PublicApi : FullAuditedEntity<Guid>, IMultiTenant
}
}
public class PublicApiParameter
public class CustomEndpointParameter
{
public string Type { get; set; } // Static, Query, Path, Body
public string Name { get; set; }
@ -66,7 +66,7 @@ public class PublicApiParameter
public bool IsRequired { get; set; }
}
public class PublicApiPermission
public class CustomEndpointPermission
{
public string ResourceType { get; set; } // Global, Role, User
public string ResourceId { get; set; }

View file

@ -43,7 +43,7 @@ public class PlatformDbContext :
public DbSet<Chart> Charts { get; set; }
public DbSet<DataSource> DataSources { get; set; }
public DbSet<BackgroundWorker> BackgroundWorkers { get; set; }
public DbSet<PublicApi> PublicApis { get; set; }
public DbSet<CustomEndpoint> CustomEndpoints { get; set; }
public DbSet<GlobalSearch> GlobalSearchs { get; set; }
public DbSet<AiBot> AiBots { get; set; }
public DbSet<Sector> Sectors { get; set; }
@ -221,9 +221,9 @@ public class PlatformDbContext :
b.ConfigureByConvention(); //auto configure for the base class props
});
builder.Entity<PublicApi>(b =>
builder.Entity<CustomEndpoint>(b =>
{
b.ToTable(PlatformConsts.DbTablePrefix + nameof(PublicApi), PlatformConsts.DbSchema);
b.ToTable(PlatformConsts.DbTablePrefix + nameof(CustomEndpoint), PlatformConsts.DbSchema);
b.ConfigureByConvention();
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Kurs.Platform.Migrations
{
/// <inheritdoc />
public partial class CustomEndpoint : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PPublicApi");
migrationBuilder.CreateTable(
name: "PCustomEndpoint",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Url = table.Column<string>(type: "nvarchar(max)", nullable: true),
Method = table.Column<string>(type: "nvarchar(max)", nullable: true),
DataSourceCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
Sql = table.Column<string>(type: "nvarchar(max)", nullable: true),
ParametersJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
PermissionsJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PCustomEndpoint", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PCustomEndpoint");
migrationBuilder.CreateTable(
name: "PPublicApi",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DataSourceCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Method = table.Column<string>(type: "nvarchar(max)", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
ParametersJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
PermissionsJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
Sql = table.Column<string>(type: "nvarchar(max)", nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Url = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PPublicApi", x => x.Id);
});
}
}
}

View file

@ -1557,6 +1557,74 @@ namespace Kurs.Platform.Migrations
b.ToTable("PCurrency", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.CustomEndpoint", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<string>("DataSourceCode")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Method")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("ParametersJson")
.HasColumnType("nvarchar(max)");
b.Property<string>("PermissionsJson")
.HasColumnType("nvarchar(max)");
b.Property<string>("Sql")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<string>("Url")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("PCustomEndpoint", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.DataSource", b =>
{
b.Property<Guid>("Id")
@ -2201,74 +2269,6 @@ namespace Kurs.Platform.Migrations
b.ToTable("PMenu", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.PublicApi", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<string>("DataSourceCode")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Method")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("ParametersJson")
.HasColumnType("nvarchar(max)");
b.Property<string>("PermissionsJson")
.HasColumnType("nvarchar(max)");
b.Property<string>("Sql")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<string>("Url")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("PPublicApi", (string)null);
});
modelBuilder.Entity("Kurs.Platform.Entities.Route", b =>
{
b.Property<Guid>("Id")

View file

@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"url": "index.html",
"revision": "0.ed5c5iithfo"
"revision": "0.q0hdfv947pg"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {