74 lines
2 KiB
C#
74 lines
2 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 PublicApi : 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<PublicApiParameter> Parameters
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(ParametersJson))
|
|||
|
|
return JsonSerializer.Deserialize<List<PublicApiParameter>>(ParametersJson);
|
|||
|
|
|
|||
|
|
return [];
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
ParametersJson = JsonSerializer.Serialize(value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[NotMapped]
|
|||
|
|
public List<PublicApiPermission> Permissions
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(PermissionsJson))
|
|||
|
|
return JsonSerializer.Deserialize<List<PublicApiPermission>>(PermissionsJson);
|
|||
|
|
|
|||
|
|
return [];
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
PermissionsJson = JsonSerializer.Serialize(value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class PublicApiParameter
|
|||
|
|
{
|
|||
|
|
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 PublicApiPermission
|
|||
|
|
{
|
|||
|
|
public string ResourceType { get; set; } // Global, Role, User
|
|||
|
|
public string ResourceId { get; set; }
|
|||
|
|
}
|