aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/HighlightTimelineService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-01-07 16:23:20 +0800
committercrupest <crupest@outlook.com>2021-01-07 16:23:20 +0800
commitdf1ef1e21d8d889a2c9abd440039533c6a43818f (patch)
treec483a2fff48ad952e787e5af1bb541d939a09f19 /BackEnd/Timeline/Services/HighlightTimelineService.cs
parent9470631c67c4740982ff2d8a16cbbb86fdd34609 (diff)
downloadtimeline-df1ef1e21d8d889a2c9abd440039533c6a43818f.tar.gz
timeline-df1ef1e21d8d889a2c9abd440039533c6a43818f.tar.bz2
timeline-df1ef1e21d8d889a2c9abd440039533c6a43818f.zip
史诗级重构!
Diffstat (limited to 'BackEnd/Timeline/Services/HighlightTimelineService.cs')
-rw-r--r--BackEnd/Timeline/Services/HighlightTimelineService.cs20
1 files changed, 6 insertions, 14 deletions
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
/// <summary>
/// Get all highlight timelines in order.
/// </summary>
- /// <returns>A list of all highlight timelines.</returns>
- Task<List<TimelineInfo>> GetHighlightTimelines();
+ /// <returns>Id list of all highlight timelines.</returns>
+ Task<List<long>> GetHighlightTimelines();
/// <summary>
/// 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<List<TimelineInfo>> GetHighlightTimelines()
+ public async Task<List<long>> GetHighlightTimelines()
{
var entities = await _database.HighlightTimelines.OrderBy(t => t.Order).Select(t => new { t.TimelineId }).ToListAsync();
- var result = new List<TimelineInfo>();
-
- foreach (var entity in entities)
- {
- result.Add(await _timelineService.GetTimelineById(entity.TimelineId));
- }
-
- return result;
+ return entities.Select(e => e.TimelineId).ToList();
}
public async Task<bool> RemoveHighlightTimeline(string timelineName, long? operatorId)