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
commit7594a16e38304739487b053405153379faee6e58 (patch)
treebb99d1a24fffc9c4142219b9c25dc66e3d2b60d2 /BackEnd/Timeline/Services/HighlightTimelineService.cs
parent97e094c97dc9ed79cf7daa0a93568e1933015bdd (diff)
downloadtimeline-7594a16e38304739487b053405153379faee6e58.tar.gz
timeline-7594a16e38304739487b053405153379faee6e58.tar.bz2
timeline-7594a16e38304739487b053405153379faee6e58.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)