From 5f9f9a9e40306f83bf360c3d27e4e33e78565fce Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Thu, 7 Nov 2019 22:06:06 +0800 Subject: Complete PersonalTimelineController and write attribute test. --- Timeline/Services/TimelineService.cs | 62 ++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 7fe32cac..28b1f91d 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Timeline.Entities; using Timeline.Models; +using Timeline.Models.Http; namespace Timeline.Services { @@ -45,7 +46,7 @@ namespace Timeline.Services /// The author's username. /// The content. /// The time of the post. If null, then use current time. - /// + /// The info of the created post. /// Thrown when or or is null. /// /// Thrown when timeline name is of bad format. @@ -61,14 +62,14 @@ namespace Timeline.Services /// /// Thrown if is of bad format. /// Thrown if does not exist. - Task CreatePost(string name, string author, string content, DateTime? time); + Task CreatePost(string name, string author, string content, DateTime? time); /// - /// Set the visibility permission of a timeline. + /// Delete a post /// /// Username or the timeline name. See remarks of . - /// The new visibility. - /// Thrown when is null. + /// The id of the post to delete. + /// Thrown when or is null. /// /// Thrown when timeline name is of bad format. /// For normal timeline, it means name is an empty string. @@ -81,14 +82,21 @@ namespace Timeline.Services /// For personal timeline, it means the user of that username does not exist /// and the inner exception should be a . /// - Task SetVisibility(string name, TimelineVisibility visibility); + /// + /// Thrown when the post with given id does not exist or is deleted already. + /// + /// + /// First use + /// to check the permission. + /// + Task DeletePost(string name, long id); /// - /// Set the description of a timeline. + /// Set the properties of a timeline. /// /// Username or the timeline name. See remarks of . - /// The new description. - /// Thrown when or is null. + /// The new properties. Null member means not to change. + /// Thrown when or is null. /// /// Thrown when timeline name is of bad format. /// For normal timeline, it means name is an empty string. @@ -101,7 +109,7 @@ namespace Timeline.Services /// For personal timeline, it means the user of that username does not exist /// and the inner exception should be a . /// - Task SetDescription(string name, string description); + Task ChangeProperty(string name, TimelinePropertyChangeRequest newProperties); /// /// Remove members to a timeline. @@ -159,6 +167,40 @@ namespace Timeline.Services /// True if can read, false if can't read. Task HasReadPermission(string name, string? username); + /// + /// Verify whether a user has the permission to modify a post. + /// + /// Username or the timeline name. See remarks of . + /// The user to check on. + /// True if can modify, false if can't modify. + /// Thrown when or is null. + /// + /// Thrown when timeline name is of bad format. + /// For normal timeline, it means name is an empty string. + /// For personal timeline, it means the username is of bad format, + /// the inner exception should be a . + /// + /// + /// Thrown when timeline does not exist. + /// For normal timeline, it means the name does not exist. + /// For personal timeline, it means the user of that username does not exist + /// and the inner exception should be a . + /// + /// + /// Thrown when the post with given id does not exist or is deleted already. + /// + /// + /// Thrown when is of bad format. + /// + /// + /// Thrown when does not exist. + /// + /// + /// This method does not check whether the user is administrator. + /// It only checks whether he is the author of the post or the owner of the timeline. + /// + Task HasPostModifyPermission(string name, long id, string username); + /// /// Verify whether a user is member of a timeline. /// -- cgit v1.2.3