From 872f0e9f094f37db9ff208d178ad5bea2fafc1a7 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 10 Feb 2021 14:31:31 +0800 Subject: ... --- BackEnd/Timeline/Services/TimelinePostService.cs | 68 ++++++++---------------- 1 file changed, 22 insertions(+), 46 deletions(-) (limited to 'BackEnd/Timeline/Services/TimelinePostService.cs') diff --git a/BackEnd/Timeline/Services/TimelinePostService.cs b/BackEnd/Timeline/Services/TimelinePostService.cs index 98841478..cea702a1 100644 --- a/BackEnd/Timeline/Services/TimelinePostService.cs +++ b/BackEnd/Timeline/Services/TimelinePostService.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading.Tasks; using Timeline.Entities; using Timeline.Helpers; +using Timeline.Helpers.Cache; using Timeline.Models; using Timeline.Models.Validation; using Timeline.Services.Exceptions; @@ -14,49 +15,15 @@ using static Timeline.Resources.Services.TimelineService; namespace Timeline.Services { - public class TimelinePostDataDigest - { - public TimelinePostDataDigest(string kind, string eTag, DateTime lastModified) - { - Kind = kind; - ETag = eTag; - LastModified = lastModified; - } - - public string Kind { get; set; } - public string ETag { get; set; } - public DateTime LastModified { get; set; } - } - - public class TimelinePostData - { - public TimelinePostData(string kind, byte[] data, string eTag, DateTime lastModified) - { - Kind = kind; - Data = data; - ETag = eTag; - LastModified = lastModified; - } - - public string Kind { get; set; } - -#pragma warning disable CA1819 // Properties should not return arrays - public byte[] Data { get; set; } -#pragma warning restore CA1819 // Properties should not return arrays - - public string ETag { get; set; } - public DateTime LastModified { get; set; } - } - public class TimelinePostCreateRequestData { - public TimelinePostCreateRequestData(string kind, byte[] data) + public TimelinePostCreateRequestData(string contentType, byte[] data) { - Kind = kind; + ContentType = contentType; Data = data; } - public string Kind { get; set; } + public string ContentType { get; set; } #pragma warning disable CA1819 // Properties should not return arrays public byte[] Data { get; set; } #pragma warning restore CA1819 // Properties should not return arrays @@ -69,14 +36,13 @@ namespace Timeline.Services /// If not set, current time is used. public DateTime? Time { get; set; } - public List Content { get; set; } = new List(); + public List DataList { get; set; } = new List(); } public class TimelinePostPatchRequest { public string? Color { get; set; } public DateTime? Time { get; set; } - public List? Content { get; set; } } public interface ITimelinePostService @@ -102,18 +68,29 @@ namespace Timeline.Services /// Thrown when post of does not exist or has been deleted. Task GetPost(long timelineId, long postId, bool includeDelete = false); - Task GetPostDataDigest(long timelineId, long postId, long dataIndex); + /// + /// Get the data digest of a post. + /// + /// The timeline id. + /// The post id. + /// The index of the data. + /// The data digest. + /// Thrown when timeline does not exist. + /// Thrown when post of does not exist or has been deleted. + /// Thrown when data of that index does not exist. + Task GetPostDataDigest(long timelineId, long postId, long dataIndex); /// /// Get the data of a post. /// - /// The id of the timeline of the post. - /// The id of the post. - /// The etag of the data. + /// The timeline id. + /// The post id. + /// The index of the data. + /// The data. /// Thrown when timeline does not exist. /// Thrown when post of does not exist or has been deleted. - /// Thrown when post has no data. - Task GetPostData(long timelineId, long postId, long dataIndex); + /// Thrown when data of that index does not exist. + Task GetPostData(long timelineId, long postId, long dataIndex); /// /// Create a new post in timeline. @@ -140,7 +117,6 @@ namespace Timeline.Services /// Thrown when is of invalid format. /// Thrown when timeline does not exist. /// Thrown when post does not exist. - /// Thrown if data is not a image. Validated by . Task PatchPost(long timelineId, long postId, TimelinePostPatchRequest request); /// -- cgit v1.2.3