From e16c958e5ba47834dc1624e09ed8e5074a60d1c6 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Apr 2021 19:20:40 +0800 Subject: refator: ... --- .../Timeline/Controllers/TimelinePostController.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs') diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs index cea873b0..2e1ed3a9 100644 --- a/BackEnd/Timeline/Controllers/TimelinePostController.cs +++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs @@ -31,31 +31,31 @@ namespace Timeline.Controllers private readonly ITimelineService _timelineService; private readonly ITimelinePostService _postService; - private readonly TimelineMapper _timelineMapper; + private readonly IGenericMapper _mapper; private readonly MarkdownProcessor _markdownProcessor; /// /// /// - public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, TimelineMapper timelineMapper, MarkdownProcessor markdownProcessor) + public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, IGenericMapper mapper, MarkdownProcessor markdownProcessor) { _timelineService = timelineService; _postService = timelinePostService; - _timelineMapper = timelineMapper; + _mapper = mapper; _markdownProcessor = markdownProcessor; } private bool UserHasAllTimelineManagementPermission => this.UserHasPermission(UserPermission.AllTimelineManagement); - private Task Map(TimelinePostEntity post, string timelineName) + private Task Map(TimelinePostEntity post) { - return _timelineMapper.MapToHttp(post, timelineName, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission); + return _mapper.MapAsync(post, Url, User); } - private Task> Map(List posts, string timelineName) + private Task> Map(List posts) { - return _timelineMapper.MapToHttp(posts, timelineName, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission); + return _mapper.MapListAsync(posts, Url, User); } /// @@ -80,7 +80,7 @@ namespace Timeline.Controllers var posts = await _postService.GetPostsAsync(timelineId, modifiedSince, includeDeleted ?? false); - var result = await Map(posts, timeline); + var result = await Map(posts); return result; } @@ -104,7 +104,7 @@ namespace Timeline.Controllers } var post = await _postService.GetPostAsync(timelineId, postId); - var result = await Map(post, timeline); + var result = await Map(post); return result; } @@ -213,7 +213,7 @@ namespace Timeline.Controllers try { var post = await _postService.CreatePostAsync(timelineId, userId, createRequest); - var result = await Map(post, timeline); + var result = await Map(post); return result; } catch (TimelinePostCreateDataException e) @@ -245,7 +245,7 @@ namespace Timeline.Controllers } var entity = await _postService.PatchPostAsync(timelineId, post, new TimelinePostPatchRequest { Time = body.Time, Color = body.Color }); - var result = await Map(entity, timeline); + var result = await Map(entity); return Ok(result); } -- cgit v1.2.3