From f1c70edd559c72dcb47ff647f3f03ba5ae9a56cc Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 21 Aug 2020 23:44:53 +0800 Subject: ... --- Timeline/Models/Http/Timeline.cs | 75 ++++++++++++++++++++++++++++++ Timeline/Models/Http/TimelineController.cs | 33 +++++++++++++ Timeline/Models/Http/UserController.cs | 6 --- Timeline/Models/Http/UserInfo.cs | 31 +++++++++++- 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs index 52e26190..6498fa74 100644 --- a/Timeline/Models/Http/Timeline.cs +++ b/Timeline/Models/Http/Timeline.cs @@ -8,45 +8,120 @@ using Timeline.Controllers; namespace Timeline.Models.Http { + /// + /// Info of post content. + /// public class TimelinePostContentInfo { + /// + /// Type of the post content. + /// public string Type { get; set; } = default!; + /// + /// If post is of text type. This is the text. + /// public string? Text { get; set; } + /// + /// If post is of image type. This is the image url. + /// public string? Url { get; set; } } + /// + /// Info of a post. + /// public class TimelinePostInfo { + /// + /// Post id. + /// public long Id { get; set; } + /// + /// Content of the post. May be null if post is deleted. + /// public TimelinePostContentInfo? Content { get; set; } + /// + /// True if post is deleted. + /// public bool Deleted { get; set; } + /// + /// Post time. + /// public DateTime Time { get; set; } + /// + /// The author. May be null if the user has been deleted. + /// public UserInfo? Author { get; set; } = default!; + /// + /// Last updated time. + /// public DateTime LastUpdated { get; set; } = default!; } + /// + /// Info of a timeline. + /// public class TimelineInfo { + /// + /// Unique id. + /// public string UniqueId { get; set; } = default!; + /// + /// Name of timeline. + /// public string Name { get; set; } = default!; + /// + /// Last modified time of timeline name. + /// public DateTime NameLastModifed { get; set; } = default!; + /// + /// Timeline description. + /// public string Description { get; set; } = default!; + /// + /// Owner of the timeline. + /// public UserInfo Owner { get; set; } = default!; + /// + /// Visibility of the timeline. + /// public TimelineVisibility Visibility { get; set; } #pragma warning disable CA2227 // Collection properties should be read only + /// + /// Members of timeline. + /// public List Members { get; set; } = default!; #pragma warning restore CA2227 // Collection properties should be read only + /// + /// Create time of timeline. + /// public DateTime CreateTime { get; set; } = default!; + /// + /// Last modified time of timeline. + /// public DateTime LastModified { get; set; } = default!; #pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// Related links. + /// public TimelineInfoLinks _links { get; set; } = default!; #pragma warning restore CA1707 // Identifiers should not contain underscores } + /// + /// Related links for timeline. + /// public class TimelineInfoLinks { + /// + /// Self. + /// public string Self { get; set; } = default!; + /// + /// Posts url. + /// public string Posts { get; set; } = default!; } diff --git a/Timeline/Models/Http/TimelineController.cs b/Timeline/Models/Http/TimelineController.cs index 3e2e6b58..aad361ee 100644 --- a/Timeline/Models/Http/TimelineController.cs +++ b/Timeline/Models/Http/TimelineController.cs @@ -4,33 +4,66 @@ using Timeline.Models.Validation; namespace Timeline.Models.Http { + /// + /// Content of post create request. + /// public class TimelinePostCreateRequestContent { + /// + /// Type of post content. + /// [Required] public string Type { get; set; } = default!; + /// + /// If post is of text type, this is the text. + /// public string? Text { get; set; } + /// + /// If post is of image type, this is base64 of image data. + /// public string? Data { get; set; } } public class TimelinePostCreateRequest { + /// + /// Content of the new post. + /// [Required] public TimelinePostCreateRequestContent Content { get; set; } = default!; + /// + /// Time of the post. If not set, current time will be used. + /// public DateTime? Time { get; set; } } + /// + /// Create timeline request model. + /// public class TimelineCreateRequest { + /// + /// Name of the new timeline. Must be a valid name. + /// [Required] [TimelineName] public string Name { get; set; } = default!; } + /// + /// Patch timeline request model. + /// public class TimelinePatchRequest { + /// + /// New description. Null for not change. + /// public string? Description { get; set; } + /// + /// New visibility. Null for not change. + /// public TimelineVisibility? Visibility { get; set; } } } diff --git a/Timeline/Models/Http/UserController.cs b/Timeline/Models/Http/UserController.cs index ea30a0ea..6bc5a66e 100644 --- a/Timeline/Models/Http/UserController.cs +++ b/Timeline/Models/Http/UserController.cs @@ -82,14 +82,8 @@ namespace Timeline.Models.Http public string NewPassword { get; set; } = default!; } - /// - /// - /// public class UserControllerAutoMapperProfile : Profile { - /// - /// - /// public UserControllerAutoMapperProfile() { CreateMap(MemberList.Source); diff --git a/Timeline/Models/Http/UserInfo.cs b/Timeline/Models/Http/UserInfo.cs index c9a26072..d92a12c4 100644 --- a/Timeline/Models/Http/UserInfo.cs +++ b/Timeline/Models/Http/UserInfo.cs @@ -2,26 +2,55 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Routing; -using System; using Timeline.Controllers; namespace Timeline.Models.Http { + /// + /// Info of a user. + /// public class UserInfo { + /// + /// Unique id. + /// public string UniqueId { get; set; } = default!; + /// + /// Username. + /// public string Username { get; set; } = default!; + /// + /// Nickname. + /// public string Nickname { get; set; } = default!; + /// + /// True if the user is a administrator. + /// public bool? Administrator { get; set; } = default!; #pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// Related links. + /// public UserInfoLinks _links { get; set; } = default!; #pragma warning restore CA1707 // Identifiers should not contain underscores } + /// + /// Related links for user. + /// public class UserInfoLinks { + /// + /// Self. + /// public string Self { get; set; } = default!; + /// + /// Avatar url. + /// public string Avatar { get; set; } = default!; + /// + /// Personal timeline url. + /// public string Timeline { get; set; } = default!; } -- cgit v1.2.3