aboutsummaryrefslogtreecommitdiff
path: root/Timeline
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-22 15:06:15 +0800
committer杨宇千 <crupest@outlook.com>2019-08-22 15:06:15 +0800
commit56ce7def278aef513204f6b4817f3de63d58cf60 (patch)
treec04c6d10452389cd88387e1076c08002bbd60414 /Timeline
parent2541f11b5d637d47b39f25cc03dc4173a6b7efe6 (diff)
downloadtimeline-56ce7def278aef513204f6b4817f3de63d58cf60.tar.gz
timeline-56ce7def278aef513204f6b4817f3de63d58cf60.tar.bz2
timeline-56ce7def278aef513204f6b4817f3de63d58cf60.zip
Add nickname in detail controller.
Diffstat (limited to 'Timeline')
-rw-r--r--Timeline/Controllers/UserDetailController.cs27
1 files changed, 24 insertions, 3 deletions
diff --git a/Timeline/Controllers/UserDetailController.cs b/Timeline/Controllers/UserDetailController.cs
index 9e1d5483..5e1183c1 100644
--- a/Timeline/Controllers/UserDetailController.cs
+++ b/Timeline/Controllers/UserDetailController.cs
@@ -10,7 +10,7 @@ using Timeline.Services;
namespace Timeline.Controllers
{
- [Route("users/{username}/details")]
+ [Route("users/{username}")]
[ProducesErrorResponseType(typeof(CommonResponse))]
[ApiController]
public class UserDetailController : Controller
@@ -22,6 +22,7 @@ namespace Timeline.Controllers
public const int Patch_Forbid = -2001;
public const int Patch_UserNotExist = -2002;
+ public const int GetNickname_UserNotExist = -3001;
}
private readonly ILogger<UserDetailController> _logger;
@@ -33,7 +34,27 @@ namespace Timeline.Controllers
_service = service;
}
- [HttpGet()]
+ [HttpGet("nickname")]
+ [UserAuthorize]
+ [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserDetail))]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ public async Task<IActionResult> GetNickname([FromRoute] string username)
+ {
+ try
+ {
+ var nickname = await _service.GetUserNickname(username);
+ return Ok(new UserDetail
+ {
+ Nickname = nickname
+ });
+ }
+ catch (UserNotExistException)
+ {
+ return NotFound(new CommonResponse(ErrorCodes.GetNickname_UserNotExist, "The user does not exist."));
+ }
+ }
+
+ [HttpGet("details")]
[UserAuthorize]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserDetail))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -50,7 +71,7 @@ namespace Timeline.Controllers
}
}
- [HttpPatch()]
+ [HttpPatch("details")]
[Authorize]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(void))]
[ProducesResponseType(StatusCodes.Status400BadRequest)]