More story fixes
This commit is contained in:
@@ -16,4 +16,12 @@ public interface IStoryMasterRepository
|
||||
|
||||
Task<StoryChapter?> GetChapterByIdAsync(int storyId);
|
||||
Task<SpecialBattleSetting?> GetSbsByIdAsync(int sbsId);
|
||||
|
||||
/// <summary>
|
||||
/// Resolve a wire story_id to a sub-chapter row when no top-level <see cref="StoryChapter"/>
|
||||
/// exists for it. Sub-chapter story_ids have no chapter master data of their own — they're
|
||||
/// progress markers hanging off the parent. Used by /finish to record progress at the sub's
|
||||
/// story_id when the client sends sub-chapter ids directly.
|
||||
/// </summary>
|
||||
Task<StorySubChapter?> FindSubChapterByStoryIdAsync(int storyId);
|
||||
}
|
||||
|
||||
@@ -51,4 +51,15 @@ public class StoryMasterRepository : IStoryMasterRepository
|
||||
|
||||
public Task<SpecialBattleSetting?> GetSbsByIdAsync(int sbsId)
|
||||
=> _db.SpecialBattleSettings.FirstOrDefaultAsync(s => s.Id == sbsId);
|
||||
|
||||
public async Task<StorySubChapter?> FindSubChapterByStoryIdAsync(int storyId)
|
||||
{
|
||||
// StorySubChapter is an owned entity (no DbSet of its own); query through the owning
|
||||
// chapter. SelectMany over the owned collection translates to a JOIN in the relational
|
||||
// provider — no need to materialize the full chapter row.
|
||||
return await _db.StoryChapters
|
||||
.AsNoTracking()
|
||||
.SelectMany(c => c.SubChapters)
|
||||
.FirstOrDefaultAsync(sc => sc.SubChapterStoryId == storyId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user