From 7594a16e38304739487b053405153379faee6e58 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 7 Jan 2021 16:23:20 +0800 Subject: 史诗级重构! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Timeline/Services/HighlightTimelineService.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'BackEnd/Timeline/Services/HighlightTimelineService.cs') diff --git a/BackEnd/Timeline/Services/HighlightTimelineService.cs b/BackEnd/Timeline/Services/HighlightTimelineService.cs index b19efe21..d0a06fe7 100644 --- a/BackEnd/Timeline/Services/HighlightTimelineService.cs +++ b/BackEnd/Timeline/Services/HighlightTimelineService.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Timeline.Entities; -using Timeline.Models; using Timeline.Services.Exceptions; namespace Timeline.Services @@ -29,8 +28,8 @@ namespace Timeline.Services /// /// Get all highlight timelines in order. /// - /// A list of all highlight timelines. - Task> GetHighlightTimelines(); + /// Id list of all highlight timelines. + Task> GetHighlightTimelines(); /// /// Add a timeline to highlight list. @@ -75,10 +74,10 @@ namespace Timeline.Services { private readonly DatabaseContext _database; private readonly IBasicUserService _userService; - private readonly ITimelineService _timelineService; + private readonly IBasicTimelineService _timelineService; private readonly IClock _clock; - public HighlightTimelineService(DatabaseContext database, IBasicUserService userService, ITimelineService timelineService, IClock clock) + public HighlightTimelineService(DatabaseContext database, IBasicUserService userService, IBasicTimelineService timelineService, IClock clock) { _database = database; _userService = userService; @@ -106,18 +105,11 @@ namespace Timeline.Services await _database.SaveChangesAsync(); } - public async Task> GetHighlightTimelines() + public async Task> GetHighlightTimelines() { var entities = await _database.HighlightTimelines.OrderBy(t => t.Order).Select(t => new { t.TimelineId }).ToListAsync(); - var result = new List(); - - foreach (var entity in entities) - { - result.Add(await _timelineService.GetTimelineById(entity.TimelineId)); - } - - return result; + return entities.Select(e => e.TimelineId).ToList(); } public async Task RemoveHighlightTimeline(string timelineName, long? operatorId) -- cgit v1.2.3