feat(import): RennmausPro-III-Backup-Importer (analyze+execute, Dedup, Fotos)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
31
GerbilManagerWebAPI/Import/Rpro3/Rpro3Guid.cs
Normal file
31
GerbilManagerWebAPI/Import/Rpro3/Rpro3Guid.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace GerbilManagerWebAPI.Import.Rpro3
|
||||
{
|
||||
/// <summary>
|
||||
/// Deterministische GUIDs aus stabilen RPRO3-Schlüsseln (analog zum Python `generate_guid`-Muster).
|
||||
/// Gleicher Schlüssel → gleiche GUID über Re-Imports hinweg → idempotent.
|
||||
/// MD5-basiert (Namespace-Präfix vermeidet Kollisionen mit anderen Entitätstypen).
|
||||
/// </summary>
|
||||
public static class Rpro3Guid
|
||||
{
|
||||
public const string ImportSource = "RennmausPro III";
|
||||
|
||||
public static Guid For(string @namespace, string key)
|
||||
{
|
||||
var bytes = MD5.HashData(Encoding.UTF8.GetBytes($"rpro3:{@namespace}:{key}"));
|
||||
return new Guid(bytes);
|
||||
}
|
||||
|
||||
public static Guid Gerbil(string clusterRootRid) => For("gerbil", clusterRootRid);
|
||||
public static Guid Litter(int wurfId) => For("litter", wurfId.ToString());
|
||||
public static Guid Contact(string ns, int id) => For("contact", $"{ns}:{id}");
|
||||
public static Guid Health(string tid, string disc, int seq) => For("health", $"{tid}:{seq}:{disc}");
|
||||
public static Guid Weight(string tid, int seq) => For("weight", $"{tid}:{seq}");
|
||||
|
||||
/// <summary>Stabiler ExternalRef-Wert (Gerbil/Litter Idempotenzschlüssel, UNIQUE-Spalte).</summary>
|
||||
public static string GerbilRef(string rootRid) => $"rpro3:{rootRid}";
|
||||
public static string LitterRef(int wurfId) => $"rpro3-wurf:{wurfId}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user