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. - 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` `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: Token İsteği Örnek:

View file

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

View file

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

View file

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

View file

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

View file

@ -347,7 +347,7 @@ public static class SeedConsts
public const string Notification = Default + ".Notification"; public const string Notification = Default + ".Notification";
} }
public const string BackgroundWorkers = Prefix.App + ".BackgroundWorkers"; 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 public static class BlogManagement
{ {

View file

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

View file

@ -43,7 +43,7 @@ public class PlatformDbContext :
public DbSet<Chart> Charts { get; set; } public DbSet<Chart> Charts { get; set; }
public DbSet<DataSource> DataSources { get; set; } public DbSet<DataSource> DataSources { get; set; }
public DbSet<BackgroundWorker> BackgroundWorkers { 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<GlobalSearch> GlobalSearchs { get; set; }
public DbSet<AiBot> AiBots { get; set; } public DbSet<AiBot> AiBots { get; set; }
public DbSet<Sector> Sectors { get; set; } public DbSet<Sector> Sectors { get; set; }
@ -221,9 +221,9 @@ public class PlatformDbContext :
b.ConfigureByConvention(); //auto configure for the base class props 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(); 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); 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 => modelBuilder.Entity("Kurs.Platform.Entities.DataSource", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -2201,74 +2269,6 @@ namespace Kurs.Platform.Migrations
b.ToTable("PMenu", (string)null); 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 => modelBuilder.Entity("Kurs.Platform.Entities.Route", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")

View file

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