85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
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;
|
||
|
||
public class CustomEndpoint : FullAuditedEntity<Guid>, IMultiTenant
|
||
{
|
||
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]
|
||
public List<CustomEndpointParameter> Parameters
|
||
{
|
||
get
|
||
{
|
||
if (!string.IsNullOrEmpty(ParametersJson))
|
||
return JsonSerializer.Deserialize<List<CustomEndpointParameter>>(ParametersJson);
|
||
|
||
return [];
|
||
}
|
||
set
|
||
{
|
||
ParametersJson = JsonSerializer.Serialize(value);
|
||
}
|
||
}
|
||
|
||
[NotMapped]
|
||
public List<CustomEndpointPermission> Permissions
|
||
{
|
||
get
|
||
{
|
||
if (!string.IsNullOrEmpty(PermissionsJson))
|
||
return JsonSerializer.Deserialize<List<CustomEndpointPermission>>(PermissionsJson);
|
||
|
||
return [];
|
||
}
|
||
set
|
||
{
|
||
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 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; }
|
||
}
|
||
|
||
public class CustomEndpointPermission
|
||
{
|
||
public string ResourceType { get; set; } // Global, Role, User
|
||
public string ResourceId { get; set; }
|
||
}
|