From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
Aging.Infrastructure/Contracts/ResourceOwnerToken.cs | 84 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/Aging.Infrastructure/Contracts/ResourceOwnerToken.cs b/Aging.Infrastructure/Contracts/ResourceOwnerToken.cs
new file mode 100644
index 0000000..3b7b9bf
--- /dev/null
+++ b/Aging.Infrastructure/Contracts/ResourceOwnerToken.cs
@@ -0,0 +1,84 @@
+using System;
+
+namespace Aging.Infrastructure.Contracts
+{
+ /// <summary>
+ /// 鎵�鏈夎�呯被鍨嬫灇涓�
+ /// </summary>
+ public enum OwnerType
+ {
+ /// <summary>
+ /// 鐢熶骇妯″紡锛堟甯歌�佸寲娴嬭瘯娴佺▼锛�
+ /// </summary>
+ Production,
+
+ /// <summary>
+ /// 缁存姢妯″紡锛堣皟璇�/缁存姢浼氳瘽锛�
+ /// </summary>
+ Maintenance
+ }
+
+ /// <summary>
+ /// 鎵�鏈夎�呬护鐗岋紝鏍囪瘑璧勬簮棰勭害鐨勫綊灞炪��
+ /// 鐢ㄤ簬鍖哄垎涓嶅悓浼氳瘽瀵圭‖浠惰祫婧愮殑鎵�鏈夋潈銆�
+ /// </summary>
+ public sealed class ResourceOwnerToken
+ {
+ /// <summary>
+ /// 浠ょ墝鍞竴鏍囪瘑
+ /// </summary>
+ public string TokenId { get; }
+
+ /// <summary>
+ /// 鎵�鏈夎�呯被鍨嬶紙鐢熶骇/缁存姢锛�
+ /// </summary>
+ public OwnerType OwnerType { get; }
+
+ /// <summary>
+ /// 鎵�鏈夎�呮爣璇嗭紙RunID 鎴� DebugSessionID锛�
+ /// </summary>
+ public string OwnerId { get; }
+
+ /// <summary>
+ /// 涓栦唬鍙凤紝姣忔鏂伴绾﹂�掑锛岄槻姝㈤噸鏀炬敾鍑�
+ /// </summary>
+ public long Generation { get; set; }
+
+ /// <summary>
+ /// 浠ょ墝绛惧彂鏃堕棿
+ /// </summary>
+ public DateTime IssuedAt { get; }
+
+ /// <summary>
+ /// 浠ょ墝杩囨湡鏃堕棿锛堝彲閫夛級
+ /// </summary>
+ public DateTime? ExpiresAt { get; }
+
+ /// <summary>
+ /// 鍒濆鍖栨墍鏈夎�呬护鐗屽疄渚�
+ /// </summary>
+ /// <param name="ownerType">鎵�鏈夎�呯被鍨�</param>
+ /// <param name="ownerId">鎵�鏈夎�呮爣璇�</param>
+ /// <param name="expiresAt">杩囨湡鏃堕棿锛堝彲閫夛級</param>
+ public ResourceOwnerToken(OwnerType ownerType, string ownerId, DateTime? expiresAt = null)
+ {
+ TokenId = Guid.NewGuid().ToString();
+ OwnerType = ownerType;
+ OwnerId = ownerId ?? throw new ArgumentNullException(nameof(ownerId));
+ Generation = 0;
+ IssuedAt = DateTime.UtcNow;
+ ExpiresAt = expiresAt;
+ }
+
+ /// <summary>
+ /// 妫�鏌ヤ护鐗屾槸鍚﹀凡杩囨湡
+ /// </summary>
+ /// <returns>杩囨湡杩斿洖 true锛涙湭璁剧疆杩囨湡鏃堕棿鎴栧皻鏈繃鏈熻繑鍥� false</returns>
+ public bool IsExpired()
+ {
+ if (!ExpiresAt.HasValue)
+ return false;
+ return DateTime.UtcNow > ExpiresAt.Value;
+ }
+ }
+}
--
Gitblit v1.9.1