使用 .NET Aspire 来编排资源 #7

Merged
LittleSheep merged 11 commits from refactor/aspire into master 2025-09-17 17:13:55 +00:00
12 changed files with 16 additions and 21 deletions
Showing only changes of commit 3caa79b9a7 - Show all commits

View File

@@ -2,9 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto;
using NodaTime; using NodaTime;
using Account = DysonNetwork.Pass.Account.Account;
namespace DysonNetwork.Sphere.Chat; namespace DysonNetwork.Sphere.Chat;
@@ -75,7 +73,7 @@ public class ChatMember : ModelBase
public Guid ChatRoomId { get; set; } public Guid ChatRoomId { get; set; }
public ChatRoom ChatRoom { get; set; } = null!; public ChatRoom ChatRoom { get; set; } = null!;
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
[NotMapped] public Account? Account { get; set; } [NotMapped] public AccountReference? Account { get; set; }
[NotMapped] public AccountStatusReference? Status { get; set; } [NotMapped] public AccountStatusReference? Status { get; set; }
[MaxLength(1024)] public string? Nick { get; set; } [MaxLength(1024)] public string? Nick { get; set; }
@@ -108,7 +106,7 @@ public class ChatMemberTransmissionObject : ModelBase
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid ChatRoomId { get; set; } public Guid ChatRoomId { get; set; }
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
[NotMapped] public Account Account { get; set; } = null!; [NotMapped] public AccountReference Account { get; set; } = null!;
[MaxLength(1024)] public string? Nick { get; set; } [MaxLength(1024)] public string? Nick { get; set; }

View File

@@ -2,7 +2,7 @@ using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Registry; using DysonNetwork.Shared.Registry;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NodaTime; using NodaTime;
using Account = DysonNetwork.Pass.Account.Account; using Account = DysonNetwork.Shared.Data.AccountReference;
namespace DysonNetwork.Sphere.Chat; namespace DysonNetwork.Sphere.Chat;

View File

@@ -161,7 +161,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DysonNetwork.ServiceDefaults\DysonNetwork.ServiceDefaults.csproj" /> <ProjectReference Include="..\DysonNetwork.ServiceDefaults\DysonNetwork.ServiceDefaults.csproj" />
<ProjectReference Include="..\DysonNetwork.Shared\DysonNetwork.Shared.csproj"/> <ProjectReference Include="..\DysonNetwork.Shared\DysonNetwork.Shared.csproj"/>
<ProjectReference Include="..\DysonNetwork.Pass\DysonNetwork.Pass.csproj"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -2,7 +2,6 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Pass.Account;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
using NodaTime; using NodaTime;
@@ -64,5 +63,5 @@ public class PollAnswer : ModelBase
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
public Guid PollId { get; set; } public Guid PollId { get; set; }
[JsonIgnore] public Poll? Poll { get; set; } [JsonIgnore] public Poll? Poll { get; set; }
[NotMapped] public Account? Account { get; set; } [NotMapped] public AccountReference? Account { get; set; }
} }

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json; using System.Text.Json;
using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Proto;
using DysonNetwork.Shared.Registry; using DysonNetwork.Shared.Registry;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@@ -116,7 +117,7 @@ public class PollController(
{ {
var protoValue = answeredAccounts.FirstOrDefault(a => a.Id == answer.AccountId.ToString()); var protoValue = answeredAccounts.FirstOrDefault(a => a.Id == answer.AccountId.ToString());
if (protoValue is not null) if (protoValue is not null)
answer.Account = Pass.Account.Account.FromProtoValue(protoValue); answer.Account = AccountReference.FromProtoValue(protoValue);
} }
} }

View File

@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore;
using NodaTime; using NodaTime;
using NodaTime.Serialization.Protobuf; using NodaTime.Serialization.Protobuf;
using VerificationMark = DysonNetwork.Shared.Data.VerificationMark; using VerificationMark = DysonNetwork.Shared.Data.VerificationMark;
using Account = DysonNetwork.Pass.Account.Account; using Account = DysonNetwork.Shared.Data.AccountReference;
namespace DysonNetwork.Sphere.Publisher; namespace DysonNetwork.Sphere.Publisher;

View File

@@ -34,7 +34,7 @@ public class PublisherController(
var account = await accounts.GetAccountAsync( var account = await accounts.GetAccountAsync(
new GetAccountRequest { Id = publisher.AccountId.Value.ToString() } new GetAccountRequest { Id = publisher.AccountId.Value.ToString() }
); );
publisher.Account = Pass.Account.Account.FromProtoValue(account); publisher.Account = AccountReference.FromProtoValue(account);
return Ok(publisher); return Ok(publisher);
} }

View File

@@ -382,7 +382,7 @@ public class PublisherService(
public async Task<PublisherMember> LoadMemberAccount(PublisherMember member) public async Task<PublisherMember> LoadMemberAccount(PublisherMember member)
{ {
var account = await accountsHelper.GetAccount(member.AccountId); var account = await accountsHelper.GetAccount(member.AccountId);
member.Account = Pass.Account.Account.FromProtoValue(account); member.Account = AccountReference.FromProtoValue(account);
return member; return member;
} }
@@ -394,7 +394,7 @@ public class PublisherService(
return members.Select(m => return members.Select(m =>
{ {
if (accounts.TryGetValue(m.AccountId, out var account)) if (accounts.TryGetValue(m.AccountId, out var account))
m.Account = Pass.Account.Account.FromProtoValue(account); m.Account = AccountReference.FromProtoValue(account);
return m; return m;
}).ToList(); }).ToList();
} }

View File

@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Pass.Account;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
using DysonNetwork.Sphere.Chat; using DysonNetwork.Sphere.Chat;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -48,7 +47,7 @@ public class RealmMember : ModelBase
public Guid RealmId { get; set; } public Guid RealmId { get; set; }
public Realm Realm { get; set; } = null!; public Realm Realm { get; set; } = null!;
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
[NotMapped] public Account? Account { get; set; } [NotMapped] public AccountReference? Account { get; set; }
[NotMapped] public AccountStatusReference? Status { get; set; } [NotMapped] public AccountStatusReference? Status { get; set; }
public int Role { get; set; } = RealmMemberRole.Normal; public int Role { get; set; } = RealmMemberRole.Normal;

View File

@@ -1,5 +1,6 @@
using DysonNetwork.Shared; using DysonNetwork.Shared;
using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Proto;
using DysonNetwork.Shared.Registry; using DysonNetwork.Shared.Registry;
using DysonNetwork.Sphere.Localization; using DysonNetwork.Sphere.Localization;
@@ -73,7 +74,7 @@ public class RealmService(
public async Task<RealmMember> LoadMemberAccount(RealmMember member) public async Task<RealmMember> LoadMemberAccount(RealmMember member)
{ {
var account = await accountsHelper.GetAccount(member.AccountId); var account = await accountsHelper.GetAccount(member.AccountId);
member.Account = Pass.Account.Account.FromProtoValue(account); member.Account = AccountReference.FromProtoValue(account);
return member; return member;
} }
@@ -85,7 +86,7 @@ public class RealmService(
return members.Select(m => return members.Select(m =>
{ {
if (accounts.TryGetValue(m.AccountId, out var account)) if (accounts.TryGetValue(m.AccountId, out var account))
m.Account = Pass.Account.Account.FromProtoValue(account); m.Account = AccountReference.FromProtoValue(account);
return m; return m;
}).ToList(); }).ToList();
} }

View File

@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Pass.Account;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -46,5 +45,5 @@ public class StickerPackOwnership : ModelBase
public Guid PackId { get; set; } public Guid PackId { get; set; }
public StickerPack Pack { get; set; } = null!; public StickerPack Pack { get; set; } = null!;
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
[NotMapped] public Account Account { get; set; } = null!; [NotMapped] public AccountReference Account { get; set; } = null!;
} }

View File

@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Pass.Account;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
namespace DysonNetwork.Sphere.WebReader; namespace DysonNetwork.Sphere.WebReader;
@@ -54,5 +53,5 @@ public class WebFeedSubscription : ModelBase
public Guid FeedId { get; set; } public Guid FeedId { get; set; }
public WebFeed Feed { get; set; } = null!; public WebFeed Feed { get; set; } = null!;
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
[NotMapped] public Account Account { get; set; } = null!; [NotMapped] public AccountReference Account { get; set; } = null!;
} }