erp-platform/api/src/Kurs.Platform.Domain/Entities/CustomEndpoint.cs

74 lines
2 KiB
C#
Raw Normal View History

2025-05-06 06:45:49 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace Kurs.Platform.Entities;
2025-07-27 18:57:19 +00:00
public class CustomEndpoint : FullAuditedEntity<Guid>, IMultiTenant
2025-05-06 06:45:49 +00:00
{
public virtual Guid? TenantId { get; protected set; }
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; } // GET, POST
public string Method { get; set; }
// DataSourceCode == "!Tenant" ise, isteği yapan kullanıcının TenantDb'sinden data çekilir
// Değilse, DataSourceCode'da belirtilen kaynaktan data çekilir
public string DataSourceCode { get; set; }
public string Sql { get; set; }
public string ParametersJson { get; set; }
public string PermissionsJson { get; set; }
[NotMapped]
2025-07-27 18:57:19 +00:00
public List<CustomEndpointParameter> Parameters
2025-05-06 06:45:49 +00:00
{
get
{
if (!string.IsNullOrEmpty(ParametersJson))
2025-07-27 18:57:19 +00:00
return JsonSerializer.Deserialize<List<CustomEndpointParameter>>(ParametersJson);
2025-05-06 06:45:49 +00:00
return [];
}
set
{
ParametersJson = JsonSerializer.Serialize(value);
}
}
[NotMapped]
2025-07-27 18:57:19 +00:00
public List<CustomEndpointPermission> Permissions
2025-05-06 06:45:49 +00:00
{
get
{
if (!string.IsNullOrEmpty(PermissionsJson))
2025-07-27 18:57:19 +00:00
return JsonSerializer.Deserialize<List<CustomEndpointPermission>>(PermissionsJson);
2025-05-06 06:45:49 +00:00
return [];
}
set
{
PermissionsJson = JsonSerializer.Serialize(value);
}
}
}
2025-07-27 18:57:19 +00:00
public class CustomEndpointParameter
2025-05-06 06:45:49 +00:00
{
public string Type { get; set; } // Static, Query, Path, Body
public string Name { get; set; }
public string DefaultValue { get; set; }
public string Path { get; set; }
public bool IsRequired { get; set; }
}
2025-07-27 18:57:19 +00:00
public class CustomEndpointPermission
2025-05-06 06:45:49 +00:00
{
public string ResourceType { get; set; } // Global, Role, User
public string ResourceId { get; set; }
}