From d922b3241245c9bc1ca6cff8ac69dd7659a958f1 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Apr 2021 19:20:40 +0800 Subject: refator: ... --- BackEnd/Timeline/Controllers/TimelineController.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'BackEnd/Timeline/Controllers/TimelineController.cs') diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs index c6b1f9ad..497d7893 100644 --- a/BackEnd/Timeline/Controllers/TimelineController.cs +++ b/BackEnd/Timeline/Controllers/TimelineController.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; @@ -28,18 +27,15 @@ namespace Timeline.Controllers { private readonly IUserService _userService; private readonly ITimelineService _service; - - private readonly TimelineMapper _timelineMapper; - private readonly IMapper _mapper; + private readonly IGenericMapper _mapper; /// /// /// - public TimelineController(IUserService userService, ITimelineService service, TimelineMapper timelineMapper, IMapper mapper) + public TimelineController(IUserService userService, ITimelineService service, IGenericMapper mapper) { _userService = userService; _service = service; - _timelineMapper = timelineMapper; _mapper = mapper; } @@ -47,12 +43,12 @@ namespace Timeline.Controllers private Task Map(TimelineEntity timeline) { - return _timelineMapper.MapToHttp(timeline, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission); + return _mapper.MapAsync(timeline, Url, User); } private Task> Map(List timelines) { - return _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission); + return _mapper.MapListAsync(timelines, Url, User); } /// @@ -157,7 +153,7 @@ namespace Timeline.Controllers try { - await _service.ChangePropertyAsync(timelineId, _mapper.Map(body)); + await _service.ChangePropertyAsync(timelineId, _mapper.AutoMapperMap(body)); var t = await _service.GetTimelineAsync(timelineId); var result = await Map(t); return result; -- cgit v1.2.3