CustomEndpoints çalışmaları
This commit is contained in:
parent
216b2a1ec9
commit
ec951d0876
5 changed files with 90 additions and 9 deletions
|
|
@ -59,11 +59,15 @@ public class CustomEndpointAppService : PlatformAppService
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Request.Path = /api/app/public-api/yxcdfn/8
|
// Request.Path = /api/app/custom-endpoint/yxcdfn/8
|
||||||
var path = httpContextAccessor.HttpContext.Request.Path.ToString()
|
var rawPath = httpContextAccessor.HttpContext.Request.Path.ToString();
|
||||||
.Replace("/api/app/public-api", "")
|
var decodedPath = Uri.UnescapeDataString(rawPath); // URL decode işlemi
|
||||||
|
|
||||||
|
var path = decodedPath
|
||||||
|
.Replace("/api/app/custom-endpoint", "", StringComparison.OrdinalIgnoreCase)
|
||||||
.EnsureStartsWith('/')
|
.EnsureStartsWith('/')
|
||||||
.EnsureEndsWith('/');
|
.EnsureEndsWith('/');
|
||||||
|
|
||||||
Logger.LogInformation("Custom Endpoint ç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)
|
||||||
|
|
@ -216,7 +220,7 @@ username=system%40sozsoft.com
|
||||||
&scope=offline_access%20Platform
|
&scope=offline_access%20Platform
|
||||||
|
|
||||||
Custom Endpoint 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]
|
||||||
,[ProductName]
|
,[ProductName]
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ public class PlatformDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
private readonly IRepository<BlogPost, Guid> _blogPostsRepository;
|
private readonly IRepository<BlogPost, Guid> _blogPostsRepository;
|
||||||
private readonly IRepository<ForumCategory, Guid> _forumCategoryRepository;
|
private readonly IRepository<ForumCategory, Guid> _forumCategoryRepository;
|
||||||
private readonly IRepository<AiBot, Guid> _aiBotRepository;
|
private readonly IRepository<AiBot, Guid> _aiBotRepository;
|
||||||
private readonly IRepository<Route, Guid> _RouteRepository;
|
private readonly IRepository<Route, Guid> _routeRepository;
|
||||||
|
private readonly IRepository<CustomEndpoint, Guid> _customEndpointRepository;
|
||||||
|
|
||||||
public PlatformDataSeeder(
|
public PlatformDataSeeder(
|
||||||
IRepository<Language, Guid> languages,
|
IRepository<Language, Guid> languages,
|
||||||
|
|
@ -86,7 +87,8 @@ public class PlatformDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
IRepository<BlogPost, Guid> blogPostsRepository,
|
IRepository<BlogPost, Guid> blogPostsRepository,
|
||||||
IRepository<ForumCategory, Guid> forumCategoryRepository,
|
IRepository<ForumCategory, Guid> forumCategoryRepository,
|
||||||
IRepository<AiBot, Guid> aiBotRepository,
|
IRepository<AiBot, Guid> aiBotRepository,
|
||||||
IRepository<Route, Guid> RouteRepository
|
IRepository<Route, Guid> RouteRepository,
|
||||||
|
IRepository<CustomEndpoint, Guid> CustomEndpointRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_languages = languages;
|
_languages = languages;
|
||||||
|
|
@ -117,7 +119,8 @@ public class PlatformDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
_blogPostsRepository = blogPostsRepository;
|
_blogPostsRepository = blogPostsRepository;
|
||||||
_forumCategoryRepository = forumCategoryRepository;
|
_forumCategoryRepository = forumCategoryRepository;
|
||||||
_aiBotRepository = aiBotRepository;
|
_aiBotRepository = aiBotRepository;
|
||||||
_RouteRepository = RouteRepository;
|
_routeRepository = RouteRepository;
|
||||||
|
_customEndpointRepository = CustomEndpointRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IConfigurationRoot BuildConfiguration()
|
private static IConfigurationRoot BuildConfiguration()
|
||||||
|
|
@ -639,11 +642,11 @@ public class PlatformDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
|
|
||||||
foreach (var item in items.Routes)
|
foreach (var item in items.Routes)
|
||||||
{
|
{
|
||||||
var exists = await _RouteRepository.AnyAsync(x => x.Key == item.Key);
|
var exists = await _routeRepository.AnyAsync(x => x.Key == item.Key);
|
||||||
|
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
await _RouteRepository.InsertAsync(new Route(
|
await _routeRepository.InsertAsync(new Route(
|
||||||
item.Key,
|
item.Key,
|
||||||
item.Path,
|
item.Path,
|
||||||
item.ComponentPath,
|
item.ComponentPath,
|
||||||
|
|
@ -652,5 +655,24 @@ public class PlatformDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var item in items.CustomEndpoints)
|
||||||
|
{
|
||||||
|
var exists = await _customEndpointRepository.AnyAsync(x => x.Name == item.Name);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
await _customEndpointRepository.InsertAsync(new CustomEndpoint(
|
||||||
|
item.Name,
|
||||||
|
item.Description,
|
||||||
|
item.Url,
|
||||||
|
item.Method,
|
||||||
|
item.DataSourceCode,
|
||||||
|
item.Sql,
|
||||||
|
JsonSerializer.Serialize(item.ParametersJson),
|
||||||
|
JsonSerializer.Serialize(item.PermissionsJson)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21698,5 +21698,34 @@
|
||||||
"routeType": "protected",
|
"routeType": "protected",
|
||||||
"authority": []
|
"authority": []
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"CustomEndpoints": [
|
||||||
|
{
|
||||||
|
"Name": "Langugage",
|
||||||
|
"Description": "https://localhost:44344/api/app/custom-endpoint/dil/en",
|
||||||
|
"Url": "/dil/",
|
||||||
|
"Method": "GET",
|
||||||
|
"DataSourceCode": "Default",
|
||||||
|
"Sql": "SELECT * FROM PLanguage WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName",
|
||||||
|
"ParametersJson": [
|
||||||
|
{
|
||||||
|
"Type": "P",
|
||||||
|
"Name": "CultureName",
|
||||||
|
"DefaultValue": "ar",
|
||||||
|
"Path": "/dil/:CultureName/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Type": "S",
|
||||||
|
"Name": "IsEnabled",
|
||||||
|
"DefaultValue": "true"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PermissionsJson": [
|
||||||
|
{
|
||||||
|
"ResourceType": "User",
|
||||||
|
"ResourceId": "system@sozsoft.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +38,7 @@ public class SeederDto
|
||||||
public List<ForumCategorySeedDto> ForumCategories { get; set; }
|
public List<ForumCategorySeedDto> ForumCategories { get; set; }
|
||||||
public List<AiBotSeedDto> AiBots { get; set; }
|
public List<AiBotSeedDto> AiBots { get; set; }
|
||||||
public List<RouteSeedDto> Routes { get; set; }
|
public List<RouteSeedDto> Routes { get; set; }
|
||||||
|
public List<CustomEndpointSeedDto> CustomEndpoints { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChartsSeedDto
|
public class ChartsSeedDto
|
||||||
|
|
@ -254,3 +255,16 @@ public class RouteSeedDto
|
||||||
public string RouteType { get; set; }
|
public string RouteType { get; set; }
|
||||||
public string[] Authority { get; set; }
|
public string[] Authority { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CustomEndpointSeedDto
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string Method { get; set; }
|
||||||
|
public string DataSourceCode { get; set; }
|
||||||
|
public string Sql { get; set; }
|
||||||
|
public List<CustomEndpointParameter> ParametersJson { get; set; }
|
||||||
|
public List<CustomEndpointPermission> PermissionsJson { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,18 @@ public class CustomEndpoint : FullAuditedEntity<Guid>, IMultiTenant
|
||||||
PermissionsJson = JsonSerializer.Serialize(value);
|
PermissionsJson = JsonSerializer.Serialize(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomEndpoint(string name, string description, string url, string method, string dataSourceCode, string sql, string parametersJson, string permissionsJson)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
Url = url;
|
||||||
|
Method = method;
|
||||||
|
DataSourceCode = dataSourceCode;
|
||||||
|
Sql = sql;
|
||||||
|
ParametersJson = parametersJson;
|
||||||
|
PermissionsJson = permissionsJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CustomEndpointParameter
|
public class CustomEndpointParameter
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue