From df1ef1e21d8d889a2c9abd440039533c6a43818f Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 7 Jan 2021 16:23:20 +0800 Subject: 史诗级重构! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BackEnd/Timeline/Models/Http/Common.cs | 120 ------------------ BackEnd/Timeline/Models/Http/CommonResponse.cs | 130 +++++++++++++++++++ BackEnd/Timeline/Models/Http/ErrorResponse.cs | 10 -- BackEnd/Timeline/Models/Http/Timeline.cs | 137 ++++++++------------- BackEnd/Timeline/Models/Http/TimelineController.cs | 3 +- BackEnd/Timeline/Models/Http/User.cs | 73 ++++------- BackEnd/Timeline/Models/Mapper/TimelineMapper.cs | 85 +++++++++++++ BackEnd/Timeline/Models/Mapper/UserMapper.cs | 38 ++++++ BackEnd/Timeline/Models/Timeline.cs | 27 ++++ BackEnd/Timeline/Models/TimelineInfo.cs | 130 ------------------- BackEnd/Timeline/Models/UserInfo.cs | 48 -------- 11 files changed, 351 insertions(+), 450 deletions(-) delete mode 100644 BackEnd/Timeline/Models/Http/Common.cs create mode 100644 BackEnd/Timeline/Models/Http/CommonResponse.cs create mode 100644 BackEnd/Timeline/Models/Mapper/TimelineMapper.cs create mode 100644 BackEnd/Timeline/Models/Mapper/UserMapper.cs create mode 100644 BackEnd/Timeline/Models/Timeline.cs delete mode 100644 BackEnd/Timeline/Models/TimelineInfo.cs delete mode 100644 BackEnd/Timeline/Models/UserInfo.cs (limited to 'BackEnd/Timeline/Models') diff --git a/BackEnd/Timeline/Models/Http/Common.cs b/BackEnd/Timeline/Models/Http/Common.cs deleted file mode 100644 index 2101a1bb..00000000 --- a/BackEnd/Timeline/Models/Http/Common.cs +++ /dev/null @@ -1,120 +0,0 @@ -using static Timeline.Resources.Models.Http.Common; - -namespace Timeline.Models.Http -{ - public class CommonResponse - { - public CommonResponse() - { - - } - - public CommonResponse(int code, string message) - { - Code = code; - Message = message; - } - - public int Code { get; set; } - public string? Message { get; set; } - } - - public class CommonDataResponse : CommonResponse - { - public CommonDataResponse() - { - - } - - public CommonDataResponse(int code, string message, T data) - : base(code, message) - { - Data = data; - } - - public T Data { get; set; } = default!; - } - - public class CommonPutResponse : CommonDataResponse - { - public class ResponseData - { - public ResponseData() { } - - public ResponseData(bool create) - { - Create = create; - } - - public bool Create { get; set; } - } - - public CommonPutResponse() - { - - } - - public CommonPutResponse(int code, string message, bool create) - : base(code, message, new ResponseData(create)) - { - - } - - internal static CommonPutResponse Create() - { - return new CommonPutResponse(0, MessagePutCreate, true); - } - - internal static CommonPutResponse Modify() - { - return new CommonPutResponse(0, MessagePutModify, false); - } - } - - /// - /// Common response for delete method. - /// - public class CommonDeleteResponse : CommonDataResponse - { - /// - public class ResponseData - { - /// - public ResponseData() { } - - /// - public ResponseData(bool delete) - { - Delete = delete; - } - - /// - /// True if the entry is deleted. False if the entry does not exist. - /// - public bool Delete { get; set; } - } - - /// - public CommonDeleteResponse() - { - - } - - /// - public CommonDeleteResponse(int code, string message, bool delete) - : base(code, message, new ResponseData(delete)) - { - - } - - internal static CommonDeleteResponse Delete() - { - return new CommonDeleteResponse(0, MessageDeleteDelete, true); - } - - internal static CommonDeleteResponse NotExist() - { - return new CommonDeleteResponse(0, MessageDeleteNotExist, false); - } - } -} diff --git a/BackEnd/Timeline/Models/Http/CommonResponse.cs b/BackEnd/Timeline/Models/Http/CommonResponse.cs new file mode 100644 index 00000000..3d0ed509 --- /dev/null +++ b/BackEnd/Timeline/Models/Http/CommonResponse.cs @@ -0,0 +1,130 @@ +using static Timeline.Resources.Models.Http.Common; + +namespace Timeline.Models.Http +{ + public class CommonResponse + { + public CommonResponse() + { + + } + + public CommonResponse(int code, string message) + { + Code = code; + Message = message; + } + + public int Code { get; set; } + public string? Message { get; set; } + } + + public class CommonDataResponse : CommonResponse + { + public CommonDataResponse() + { + + } + + public CommonDataResponse(int code, string message, T data) + : base(code, message) + { + Data = data; + } + + public T Data { get; set; } = default!; + } + + public class CommonPutResponse : CommonDataResponse + { + public class ResponseData + { + public ResponseData() { } + + public ResponseData(bool create) + { + Create = create; + } + + public bool Create { get; set; } + } + + public CommonPutResponse() + { + + } + + public CommonPutResponse(int code, string message, bool create) + : base(code, message, new ResponseData(create)) + { + + } + + internal static CommonPutResponse Create(bool create) + { + return new CommonPutResponse(0, MessagePutCreate, create); + } + + internal static CommonPutResponse Create() + { + return new CommonPutResponse(0, MessagePutCreate, true); + } + + internal static CommonPutResponse Modify() + { + return new CommonPutResponse(0, MessagePutModify, false); + } + } + + /// + /// Common response for delete method. + /// + public class CommonDeleteResponse : CommonDataResponse + { + /// + public class ResponseData + { + /// + public ResponseData() { } + + /// + public ResponseData(bool delete) + { + Delete = delete; + } + + /// + /// True if the entry is deleted. False if the entry does not exist. + /// + public bool Delete { get; set; } + } + + /// + public CommonDeleteResponse() + { + + } + + /// + public CommonDeleteResponse(int code, string message, bool delete) + : base(code, message, new ResponseData(delete)) + { + + } + + internal static CommonDeleteResponse Create(bool delete) + { + return new CommonDeleteResponse(0, MessageDeleteDelete, delete); + } + + internal static CommonDeleteResponse Delete() + { + return new CommonDeleteResponse(0, MessageDeleteDelete, true); + } + + internal static CommonDeleteResponse NotExist() + { + return new CommonDeleteResponse(0, MessageDeleteNotExist, false); + } + } +} diff --git a/BackEnd/Timeline/Models/Http/ErrorResponse.cs b/BackEnd/Timeline/Models/Http/ErrorResponse.cs index 10755fd1..1bc46680 100644 --- a/BackEnd/Timeline/Models/Http/ErrorResponse.cs +++ b/BackEnd/Timeline/Models/Http/ErrorResponse.cs @@ -234,16 +234,6 @@ namespace Timeline.Models.Http return new CommonResponse(ErrorCodes.TimelineController.NotExist, string.Format(message, formatArgs)); } - public static CommonResponse MemberPut_NotExist(params object?[] formatArgs) - { - return new CommonResponse(ErrorCodes.TimelineController.MemberPut_NotExist, string.Format(TimelineController_MemberPut_NotExist, formatArgs)); - } - - public static CommonResponse CustomMessage_MemberPut_NotExist(string message, params object?[] formatArgs) - { - return new CommonResponse(ErrorCodes.TimelineController.MemberPut_NotExist, string.Format(message, formatArgs)); - } - public static CommonResponse QueryRelateNotExist(params object?[] formatArgs) { return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(TimelineController_QueryRelateNotExist, formatArgs)); diff --git a/BackEnd/Timeline/Models/Http/Timeline.cs b/BackEnd/Timeline/Models/Http/Timeline.cs index 8e3831e1..06fa4e5a 100644 --- a/BackEnd/Timeline/Models/Http/Timeline.cs +++ b/BackEnd/Timeline/Models/Http/Timeline.cs @@ -1,10 +1,5 @@ -using AutoMapper; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Routing; -using System; +using System; using System.Collections.Generic; -using Timeline.Controllers; namespace Timeline.Models.Http { @@ -13,6 +8,16 @@ namespace Timeline.Models.Http /// public class HttpTimelinePostContent { + public HttpTimelinePostContent() { } + + public HttpTimelinePostContent(string type, string? text, string? url, string? eTag) + { + Type = type; + Text = text; + Url = url; + ETag = eTag; + } + /// /// Type of the post content. /// @@ -36,6 +41,18 @@ namespace Timeline.Models.Http /// public class HttpTimelinePost { + public HttpTimelinePost() { } + + public HttpTimelinePost(long id, HttpTimelinePostContent? content, bool deleted, DateTime time, HttpUser? author, DateTime lastUpdated) + { + Id = id; + Content = content; + Deleted = deleted; + Time = time; + Author = author; + LastUpdated = lastUpdated; + } + /// /// Post id. /// @@ -67,6 +84,23 @@ namespace Timeline.Models.Http /// public class HttpTimeline { + public HttpTimeline() { } + + public HttpTimeline(string uniqueId, string title, string name, DateTime nameLastModifed, string description, HttpUser owner, TimelineVisibility visibility, List members, DateTime createTime, DateTime lastModified, HttpTimelineLinks links) + { + UniqueId = uniqueId; + Title = title; + Name = name; + NameLastModifed = nameLastModifed; + Description = description; + Owner = owner; + Visibility = visibility; + Members = members; + CreateTime = createTime; + LastModified = lastModified; + _links = links; + } + /// /// Unique id. /// @@ -123,6 +157,14 @@ namespace Timeline.Models.Http /// public class HttpTimelineLinks { + public HttpTimelineLinks() { } + + public HttpTimelineLinks(string self, string posts) + { + Self = self; + Posts = posts; + } + /// /// Self. /// @@ -132,87 +174,4 @@ namespace Timeline.Models.Http /// public string Posts { get; set; } = default!; } - - public class HttpTimelineLinksValueResolver : IValueResolver - { - private readonly IActionContextAccessor _actionContextAccessor; - private readonly IUrlHelperFactory _urlHelperFactory; - - public HttpTimelineLinksValueResolver(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory) - { - _actionContextAccessor = actionContextAccessor; - _urlHelperFactory = urlHelperFactory; - } - - public HttpTimelineLinks Resolve(TimelineInfo source, HttpTimeline destination, HttpTimelineLinks destMember, ResolutionContext context) - { - var actionContext = _actionContextAccessor.AssertActionContextForUrlFill(); - var urlHelper = _urlHelperFactory.GetUrlHelper(actionContext); - - return new HttpTimelineLinks - { - Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { source.Name }), - Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { source.Name }) - }; - } - } - - public class HttpTimelinePostContentResolver : IValueResolver - { - private readonly IActionContextAccessor _actionContextAccessor; - private readonly IUrlHelperFactory _urlHelperFactory; - - public HttpTimelinePostContentResolver(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory) - { - _actionContextAccessor = actionContextAccessor; - _urlHelperFactory = urlHelperFactory; - } - - public HttpTimelinePostContent? Resolve(TimelinePostInfo source, HttpTimelinePost destination, HttpTimelinePostContent? destMember, ResolutionContext context) - { - var actionContext = _actionContextAccessor.AssertActionContextForUrlFill(); - var urlHelper = _urlHelperFactory.GetUrlHelper(actionContext); - - var sourceContent = source.Content; - - if (sourceContent == null) - { - return null; - } - - if (sourceContent is TextTimelinePostContent textContent) - { - return new HttpTimelinePostContent - { - Type = TimelinePostContentTypes.Text, - Text = textContent.Text - }; - } - else if (sourceContent is ImageTimelinePostContent imageContent) - { - return new HttpTimelinePostContent - { - Type = TimelinePostContentTypes.Image, - Url = urlHelper.ActionLink( - action: nameof(TimelineController.PostDataGet), - controller: nameof(TimelineController)[0..^nameof(Controller).Length], - values: new { Name = source.TimelineName, Id = source.Id }), - ETag = $"\"{imageContent.DataTag}\"" - }; - } - else - { - throw new InvalidOperationException(Resources.Models.Http.Exception.UnknownPostContentType); - } - } - } - - public class HttpTimelineAutoMapperProfile : Profile - { - public HttpTimelineAutoMapperProfile() - { - CreateMap().ForMember(u => u._links, opt => opt.MapFrom()); - CreateMap().ForMember(p => p.Content, opt => opt.MapFrom()); - } - } } diff --git a/BackEnd/Timeline/Models/Http/TimelineController.cs b/BackEnd/Timeline/Models/Http/TimelineController.cs index 42a926fd..f6039b35 100644 --- a/BackEnd/Timeline/Models/Http/TimelineController.cs +++ b/BackEnd/Timeline/Models/Http/TimelineController.cs @@ -2,6 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; using Timeline.Models.Validation; +using Timeline.Services; namespace Timeline.Models.Http { @@ -96,7 +97,7 @@ namespace Timeline.Models.Http { public HttpTimelineControllerAutoMapperProfile() { - CreateMap(); + CreateMap(); } } } diff --git a/BackEnd/Timeline/Models/Http/User.cs b/BackEnd/Timeline/Models/Http/User.cs index bdb40b9f..994c08bf 100644 --- a/BackEnd/Timeline/Models/Http/User.cs +++ b/BackEnd/Timeline/Models/Http/User.cs @@ -1,10 +1,4 @@ -using AutoMapper; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Routing; -using System.Collections.Generic; -using Timeline.Controllers; -using Timeline.Services; +using System.Collections.Generic; namespace Timeline.Models.Http { @@ -13,6 +7,17 @@ namespace Timeline.Models.Http /// public class HttpUser { + public HttpUser() { } + + public HttpUser(string uniqueId, string username, string nickname, List permissions, HttpUserLinks links) + { + UniqueId = uniqueId; + Username = username; + Nickname = nickname; + Permissions = permissions; + _links = links; + } + /// /// Unique id. /// @@ -44,6 +49,15 @@ namespace Timeline.Models.Http /// public class HttpUserLinks { + public HttpUserLinks() { } + + public HttpUserLinks(string self, string avatar, string timeline) + { + Self = self; + Avatar = avatar; + Timeline = timeline; + } + /// /// Self. /// @@ -57,49 +71,4 @@ namespace Timeline.Models.Http /// public string Timeline { get; set; } = default!; } - - public class HttpUserPermissionsValueConverter : ITypeConverter> - { - public List Convert(UserPermissions source, List destination, ResolutionContext context) - { - return source.ToStringList(); - } - } - - public class HttpUserLinksValueResolver : IValueResolver - { - private readonly IActionContextAccessor _actionContextAccessor; - private readonly IUrlHelperFactory _urlHelperFactory; - - public HttpUserLinksValueResolver(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory) - { - _actionContextAccessor = actionContextAccessor; - _urlHelperFactory = urlHelperFactory; - } - - public HttpUserLinks Resolve(UserInfo source, HttpUser destination, HttpUserLinks destMember, ResolutionContext context) - { - var actionContext = _actionContextAccessor.AssertActionContextForUrlFill(); - var urlHelper = _urlHelperFactory.GetUrlHelper(actionContext); - - var result = new HttpUserLinks - { - Self = urlHelper.ActionLink(nameof(UserController.Get), nameof(UserController)[0..^nameof(Controller).Length], new { destination.Username }), - Avatar = urlHelper.ActionLink(nameof(UserAvatarController.Get), nameof(UserAvatarController)[0..^nameof(Controller).Length], new { destination.Username }), - Timeline = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { Name = "@" + destination.Username }) - }; - return result; - } - } - - public class HttpUserAutoMapperProfile : Profile - { - public HttpUserAutoMapperProfile() - { - CreateMap>() - .ConvertUsing(); - CreateMap() - .ForMember(u => u._links, opt => opt.MapFrom()); - } - } } diff --git a/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs b/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs new file mode 100644 index 00000000..89a5c0c8 --- /dev/null +++ b/BackEnd/Timeline/Models/Mapper/TimelineMapper.cs @@ -0,0 +1,85 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Timeline.Controllers; +using Timeline.Entities; +using Timeline.Models.Http; +using Timeline.Services; + +namespace Timeline.Models.Mapper +{ + public static class TimelineMapper + { + public static HttpTimeline MapToHttp(this TimelineEntity entity, IUrlHelper urlHelper) + { + var timelineName = entity.Name is null ? "@" + entity.Owner.Username : entity.Name; + + return new HttpTimeline( + uniqueId: entity.UniqueId, + title: string.IsNullOrEmpty(entity.Title) ? timelineName : entity.Title, + name: timelineName, + nameLastModifed: entity.NameLastModified, + description: entity.Description ?? "", + owner: entity.Owner.MapToHttp(urlHelper), + visibility: entity.Visibility, + members: entity.Members.Select(m => m.User.MapToHttp(urlHelper)).ToList(), + createTime: entity.CreateTime, + lastModified: entity.LastModified, + links: new HttpTimelineLinks( + self: urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { timeline = timelineName }), + posts: urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { timeline = timelineName }) + ) + ); + } + + public static List MapToHttp(this List entites, IUrlHelper urlHelper) + { + return entites.Select(e => e.MapToHttp(urlHelper)).ToList(); + } + + + public static HttpTimelinePost MapToHttp(this TimelinePostEntity entity, string timelineName, IUrlHelper urlHelper) + { + HttpTimelinePostContent? content = null; + + if (entity.Content != null) + { + content = entity.ContentType switch + { + TimelinePostContentTypes.Text => new HttpTimelinePostContent + ( + type: TimelinePostContentTypes.Text, + text: entity.Content, + url: null, + eTag: null + ), + TimelinePostContentTypes.Image => new HttpTimelinePostContent + ( + type: TimelinePostContentTypes.Image, + text: null, + url: urlHelper.ActionLink(nameof(TimelineController.PostDataGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { timeline = timelineName, post = entity.LocalId }), + eTag: $"\"{entity.Content}\"" + ), + _ => throw new DatabaseCorruptedException(string.Format(CultureInfo.InvariantCulture, "Unknown timeline post type {0}.", entity.ContentType)) + }; + } + + return new HttpTimelinePost( + id: entity.LocalId, + content: content, + deleted: content is null, + time: entity.Time, + author: entity.Author?.MapToHttp(urlHelper), + lastUpdated: entity.LastUpdated + ); + } + + public static List MapToHttp(this List entities, string timelineName, IUrlHelper urlHelper) + { + return entities.Select(e => e.MapToHttp(timelineName, urlHelper)).ToList(); + } + } +} diff --git a/BackEnd/Timeline/Models/Mapper/UserMapper.cs b/BackEnd/Timeline/Models/Mapper/UserMapper.cs new file mode 100644 index 00000000..3255dca9 --- /dev/null +++ b/BackEnd/Timeline/Models/Mapper/UserMapper.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Linq; +using Timeline.Controllers; +using Timeline.Entities; +using Timeline.Models.Http; +using Timeline.Services; + +namespace Timeline.Models.Mapper +{ + public static class UserMapper + { + public static HttpUser MapToHttp(this UserEntity entity, IUrlHelper urlHelper) + { + return new HttpUser( + uniqueId: entity.UniqueId, + username: entity.Username, + nickname: string.IsNullOrEmpty(entity.Nickname) ? entity.Username : entity.Nickname, + permissions: MapPermission(entity), + links: new HttpUserLinks( + self: urlHelper.ActionLink(nameof(UserController.Get), nameof(UserController)[0..^nameof(Controller).Length], new { entity.Username }), + avatar: urlHelper.ActionLink(nameof(UserAvatarController.Get), nameof(UserAvatarController)[0..^nameof(Controller).Length], new { entity.Username }), + timeline: urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { timeline = "@" + entity.Username }) + ) + ); + } + + public static List MapToHttp(this List entities, IUrlHelper urlHelper) + { + return entities.Select(e => e.MapToHttp(urlHelper)).ToList(); + } + + private static List MapPermission(UserEntity entity) + { + return entity.Permissions.Select(p => p.Permission).ToList(); + } + } +} diff --git a/BackEnd/Timeline/Models/Timeline.cs b/BackEnd/Timeline/Models/Timeline.cs new file mode 100644 index 00000000..fa3c0eb3 --- /dev/null +++ b/BackEnd/Timeline/Models/Timeline.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace Timeline.Models +{ + public enum TimelineVisibility + { + /// + /// All people including those without accounts. + /// + Public, + /// + /// Only people signed in. + /// + Register, + /// + /// Only member. + /// + Private + } + + public static class TimelinePostContentTypes + { + public const string Text = "text"; + public const string Image = "image"; + } +} diff --git a/BackEnd/Timeline/Models/TimelineInfo.cs b/BackEnd/Timeline/Models/TimelineInfo.cs deleted file mode 100644 index 649af274..00000000 --- a/BackEnd/Timeline/Models/TimelineInfo.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Timeline.Models -{ - public enum TimelineVisibility - { - /// - /// All people including those without accounts. - /// - Public, - /// - /// Only people signed in. - /// - Register, - /// - /// Only member. - /// - Private - } - - public static class TimelinePostContentTypes - { - public const string Text = "text"; - public const string Image = "image"; - } - - public interface ITimelinePostContent - { - public string Type { get; } - } - - public class TextTimelinePostContent : ITimelinePostContent - { - public TextTimelinePostContent(string text) { Text = text; } - - public string Type { get; } = TimelinePostContentTypes.Text; - public string Text { get; set; } - } - - public class ImageTimelinePostContent : ITimelinePostContent - { - public ImageTimelinePostContent(string dataTag) { DataTag = dataTag; } - - public string Type { get; } = TimelinePostContentTypes.Image; - - /// - /// The tag of the data. The tag of the entry in DataManager. Also the etag (not quoted). - /// - public string DataTag { get; set; } - } - - public class TimelinePostInfo - { - public TimelinePostInfo() - { - - } - - public TimelinePostInfo(long id, ITimelinePostContent? content, DateTime time, UserInfo? author, DateTime lastUpdated, string timelineName) - { - Id = id; - Content = content; - Time = time; - Author = author; - LastUpdated = lastUpdated; - TimelineName = timelineName; - } - - public long Id { get; set; } - public ITimelinePostContent? Content { get; set; } - public bool Deleted => Content == null; - public DateTime Time { get; set; } - public UserInfo? Author { get; set; } - public DateTime LastUpdated { get; set; } - public string TimelineName { get; set; } = default!; - } - - public class TimelineInfo - { - public TimelineInfo() - { - - } - - public TimelineInfo( - string uniqueId, - string name, - DateTime nameLastModified, - string title, - string description, - UserInfo owner, - TimelineVisibility visibility, - List members, - DateTime createTime, - DateTime lastModified) - { - UniqueId = uniqueId; - Name = name; - NameLastModified = nameLastModified; - Title = title; - Description = description; - Owner = owner; - Visibility = visibility; - Members = members; - CreateTime = createTime; - LastModified = lastModified; - } - - public string UniqueId { get; set; } = default!; - public string Name { get; set; } = default!; - public DateTime NameLastModified { get; set; } = default!; - public string Title { get; set; } = default!; - public string Description { get; set; } = default!; - public UserInfo Owner { get; set; } = default!; - public TimelineVisibility Visibility { get; set; } -#pragma warning disable CA2227 // Collection properties should be read only - public List Members { get; set; } = default!; -#pragma warning restore CA2227 // Collection properties should be read only - public DateTime CreateTime { get; set; } = default!; - public DateTime LastModified { get; set; } = default!; - } - - public class TimelineChangePropertyRequest - { - public string? Title { get; set; } - public string? Description { get; set; } - public TimelineVisibility? Visibility { get; set; } - } -} diff --git a/BackEnd/Timeline/Models/UserInfo.cs b/BackEnd/Timeline/Models/UserInfo.cs deleted file mode 100644 index e8d57def..00000000 --- a/BackEnd/Timeline/Models/UserInfo.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Timeline.Services; - -namespace Timeline.Models -{ - public class UserInfo - { - public UserInfo() - { - - } - - public UserInfo( - long id, - string uniqueId, - string username, - string nickname, - UserPermissions permissions, - DateTime usernameChangeTime, - DateTime createTime, - DateTime lastModified, - long version) - { - Id = id; - UniqueId = uniqueId; - Username = username; - Nickname = nickname; - Permissions = permissions; - UsernameChangeTime = usernameChangeTime; - CreateTime = createTime; - LastModified = lastModified; - Version = version; - } - - public long Id { get; set; } - public string UniqueId { get; set; } = default!; - - public string Username { get; set; } = default!; - public string Nickname { get; set; } = default!; - - public UserPermissions Permissions { get; set; } = default!; - - public DateTime UsernameChangeTime { get; set; } - public DateTime CreateTime { get; set; } - public DateTime LastModified { get; set; } - public long Version { get; set; } - } -} -- cgit v1.2.3