Работа над маршрутизацией

This commit is contained in:
2025-10-06 17:50:53 +04:00
parent 94c9ce1264
commit fd80bdc93e
7 changed files with 99 additions and 32 deletions
+2 -1
View File
@@ -215,9 +215,10 @@ public class EntitySerializer
{
var entity = (IEntity)value;
var entityType = entity.Entity.Type;
var typeName = PgNameHelper.GetPgName(entityType);
var slug = entity.Entity.Slug;
var name = entity.Entity.Name[LocaleType.English];
return ($"<a href=\"/Entity/{entityType}/{slug}\">{name}</a>", true);
return ($"<a href=\"/{typeName}/{slug}\">{name}</a>", true);
}
// Обработка коллекций
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Reflection;
using NpgsqlTypes;
using Pf2e.Database.Model.Enum;
namespace Pf2e.Web.Helpers
{
public static class PgNameHelper
{
public static string GetPgName(EntityType entityType)
{
var fieldInfo = entityType.GetType().GetField(entityType.ToString());
var pgNameAttribute = fieldInfo?.GetCustomAttribute<PgNameAttribute>();
return pgNameAttribute?.PgName ?? entityType.ToString().ToLower();
}
}
}