C1: replay_detail — flatten stored payload to data level. ChatReplayDetailTask.Parse() calls new ReplayDetailInfo(data) which unguardedly accesses data[battleId], data[seed], data[vid1], etc. Wrapping under replay_info key crashes the client. Controller now returns Ok(JsonElement) directly so stored battle fields are at data root. Wire-shape test added. C2: Guild.LeaderViewerId long to long?; add HasOne<Viewer> FK with OnDelete=SetNull; migration AddGuildLeaderViewerIdFk; all consumers null-guarded with ?? 0L. C3: BreakupAsync — wrap 6 destructive ops in IDbContextTransaction with InMemory fallback. C4: CommitJoinAsync — wrap member-add + viewer-guildId-set + invite/request cleanup in IDbContextTransaction with InMemory fallback. Chat event emitted after commit. I1: GuildController — remove SVSimDbContext field; inject IViewerRepository + IGuildMemberRepository. Add IGuildMemberRepository.GetViewerIdsInAGuildAsync (batch guild-membership check). All _db.Viewers / _db.GuildMembers queries replaced with repo calls. I2: GuildService — extract 3 _db.Viewers queries: GetEquippedEmblemIdAsync (CreateAsync), LoadGuildProfileBatchAsync (ListOutgoingInvitesAsync + ListPendingJoinRequestsForMyGuildAsync). Add GuildMemberProfile record with IsOfficialMarkDisplayed. GetEmblemListAsync for EmblemList. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
1.4 KiB
C#
26 lines
1.4 KiB
C#
using SVSim.Database.Entities.Guild;
|
|
|
|
namespace SVSim.Database.Repositories.Guild;
|
|
|
|
public interface IGuildMemberRepository
|
|
{
|
|
Task<GuildMember?> GetMembershipAsync(long viewerId, CancellationToken ct = default);
|
|
Task<IReadOnlyList<GuildMember>> ListByGuildAsync(int guildId, CancellationToken ct = default);
|
|
Task<int> CountByGuildAsync(int guildId, CancellationToken ct = default);
|
|
Task<int> CountByGuildAndRoleAsync(int guildId, GuildRole role, CancellationToken ct = default);
|
|
Task AddAsync(GuildMember m, CancellationToken ct = default);
|
|
Task UpdateRoleAsync(int guildId, long viewerId, GuildRole role, CancellationToken ct = default);
|
|
Task RemoveAsync(int guildId, long viewerId, CancellationToken ct = default);
|
|
Task DeleteAllForGuildAsync(int guildId, CancellationToken ct = default);
|
|
|
|
/// <summary>Returns a count of members per guild for the given guild ids. Used by Task 9 search.</summary>
|
|
Task<Dictionary<int, int>> CountBatchByGuildIdsAsync(IReadOnlyList<int> guildIds, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Batch-checks whether each viewer id in <paramref name="viewerIds"/> is currently in any guild.
|
|
/// Returns a set of viewer ids that ARE in a guild. Used by <c>/guild/friend_list</c> to set
|
|
/// <c>is_join_guild</c>.
|
|
/// </summary>
|
|
Task<HashSet<long>> GetViewerIdsInAGuildAsync(IReadOnlyList<long> viewerIds, CancellationToken ct = default);
|
|
}
|