diff options
author | crupest <crupest@outlook.com> | 2022-04-12 21:06:26 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-04-12 21:06:26 +0800 |
commit | 7715ddd0d70efc32bf3d04d2b2c356c333328344 (patch) | |
tree | 836ed52c1738cf7bfbd3e120c466ec8eab18c8f8 /BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs | |
parent | 281ae3c3458bf022a659b04e0f269c0f0d21d34b (diff) | |
download | timeline-7715ddd0d70efc32bf3d04d2b2c356c333328344.tar.gz timeline-7715ddd0d70efc32bf3d04d2b2c356c333328344.tar.bz2 timeline-7715ddd0d70efc32bf3d04d2b2c356c333328344.zip |
...
Diffstat (limited to 'BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs b/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs index 7f620928..7bc02dc2 100644 --- a/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs +++ b/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs @@ -2,11 +2,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Timeline.Entities; using Timeline.Models.Http; using Timeline.Models.Validation; using Timeline.Services; -using Timeline.Services.Mapper; using Timeline.Services.Timeline; using Timeline.Services.User; @@ -17,27 +15,20 @@ namespace Timeline.Controllers.V2 public class TimelineV2Controller : V2ControllerBase { private ITimelineService _timelineService; - private IGenericMapper _mapper; private IUserService _userService; - public TimelineV2Controller(ITimelineService timelineService, IGenericMapper mapper, IUserService userService) + public TimelineV2Controller(ITimelineService timelineService, IUserService userService) { _timelineService = timelineService; - _mapper = mapper; _userService = userService; } - private Task<HttpTimeline> MapAsync(TimelineEntity entity) - { - return _mapper.MapAsync<HttpTimeline>(entity, Url, User); - } - [HttpGet("{owner}/{timeline}")] public async Task<ActionResult<HttpTimeline>> GetAsync([FromRoute][Username] string owner, [FromRoute][TimelineName] string timeline) { var timelineId = await _timelineService.GetTimelineIdAsync(owner, timeline); var t = await _timelineService.GetTimelineAsync(timelineId); - return await MapAsync(t); + return await MapAsync<HttpTimeline>(t); } [HttpPatch("{owner}/{timeline}")] @@ -54,9 +45,9 @@ namespace Timeline.Controllers.V2 { return Forbid(); } - await _timelineService.ChangePropertyAsync(timelineId, _mapper.AutoMapperMap<TimelineChangePropertyParams>(body)); + await _timelineService.ChangePropertyAsync(timelineId, AutoMapperMap<TimelineChangePropertyParams>(body)); var t = await _timelineService.GetTimelineAsync(timelineId); - return await MapAsync(t); + return await MapAsync<HttpTimeline>(t); } [HttpDelete("{owner}/{timeline}")] @@ -144,7 +135,7 @@ namespace Timeline.Controllers.V2 var authUserId = GetAuthUserId(); var authUser = await _userService.GetUserAsync(authUserId); var timeline = await _timelineService.CreateTimelineAsync(authUserId, body.Name); - var result = await MapAsync(timeline); + var result = await MapAsync<HttpTimeline>(timeline); return CreatedAtAction("Get", new { owner = authUser.Username, timeline = body.Name }, result); } } |