aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/UserController.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-08 17:19:38 +0800
committer杨宇千 <crupest@outlook.com>2019-08-08 17:19:38 +0800
commitaa7d7d8ce33646dc63afb0c084e7daa14916646a (patch)
tree676dd1a733fb0faa8fd2ca142fd8299a860c19b7 /Timeline/Controllers/UserController.cs
parenta35030d0a379ed7ee7fdd403449f53743209059c (diff)
downloadtimeline-aa7d7d8ce33646dc63afb0c084e7daa14916646a.tar.gz
timeline-aa7d7d8ce33646dc63afb0c084e7daa14916646a.tar.bz2
timeline-aa7d7d8ce33646dc63afb0c084e7daa14916646a.zip
Rename user yo users in route.
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r--Timeline/Controllers/UserController.cs18
1 files changed, 9 insertions, 9 deletions
diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs
index 28d9523a..af4cfb53 100644
--- a/Timeline/Controllers/UserController.cs
+++ b/Timeline/Controllers/UserController.cs
@@ -16,11 +16,11 @@ namespace Timeline.Controllers
{
private static class ErrorCodes
{
- public const int Get_NotExists = -1001;
+ public const int Get_NotExist = -1001;
- public const int Patch_NotExists = -3001;
+ public const int Patch_NotExist = -2001;
- public const int ChangePassword_BadOldPassword = -4001;
+ public const int ChangePassword_BadOldPassword = -3001;
}
private readonly ILogger<UserController> _logger;
@@ -38,19 +38,19 @@ namespace Timeline.Controllers
return Ok(await _userService.ListUsers());
}
- [HttpGet("user/{username}"), AdminAuthorize]
+ [HttpGet("users/{username}"), AdminAuthorize]
public async Task<IActionResult> Get([FromRoute] string username)
{
var user = await _userService.GetUser(username);
if (user == null)
{
_logger.LogInformation(FormatLogMessage("Attempt to get a non-existent user.", Pair("Username", username)));
- return NotFound(new CommonResponse(ErrorCodes.Get_NotExists, "The user does not exist."));
+ return NotFound(new CommonResponse(ErrorCodes.Get_NotExist, "The user does not exist."));
}
return Ok(user);
}
- [HttpPut("user/{username}"), AdminAuthorize]
+ [HttpPut("users/{username}"), AdminAuthorize]
public async Task<IActionResult> Put([FromBody] UserPutRequest request, [FromRoute] string username)
{
var result = await _userService.PutUser(username, request.Password, request.Administrator.Value);
@@ -67,7 +67,7 @@ namespace Timeline.Controllers
}
}
- [HttpPatch("user/{username}"), AdminAuthorize]
+ [HttpPatch("users/{username}"), AdminAuthorize]
public async Task<IActionResult> Patch([FromBody] UserPatchRequest request, [FromRoute] string username)
{
try
@@ -78,11 +78,11 @@ namespace Timeline.Controllers
catch (UserNotExistException e)
{
_logger.LogInformation(e, FormatLogMessage("Attempt to patch a non-existent user.", Pair("Username", username)));
- return BadRequest(new CommonResponse(ErrorCodes.Patch_NotExists, "The user does not exist."));
+ return BadRequest(new CommonResponse(ErrorCodes.Patch_NotExist , "The user does not exist."));
}
}
- [HttpDelete("user/{username}"), AdminAuthorize]
+ [HttpDelete("users/{username}"), AdminAuthorize]
public async Task<IActionResult> Delete([FromRoute] string username)
{
try