From 53888df71f7580bf169dfab3d13d313cf96d26df Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 21 Aug 2020 21:25:33 +0800 Subject: ... --- Timeline/Controllers/TimelineController.cs | 48 ++++++---------------------- Timeline/Controllers/TokenController.cs | 10 +++--- Timeline/Controllers/UserAvatarController.cs | 8 +---- Timeline/Controllers/UserController.cs | 39 +++++++++------------- 4 files changed, 29 insertions(+), 76 deletions(-) (limited to 'Timeline/Controllers') diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index b376bce5..43178ac6 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -49,8 +49,7 @@ namespace Timeline.Controllers /// A username. If set, only timelines related to the user will return. /// Specify the relation type, may be 'own' or 'join'. If not set, both type will return. /// "Private" or "Register" or "Public". If set, only timelines whose visibility is specified one will return. - /// Succeeded to get timelines. - /// Model is invalid. Or user specified by "relate" param does not exist. + /// The timeline list. [HttpGet("timelines")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] @@ -117,9 +116,7 @@ namespace Timeline.Controllers /// A unique id. If specified and if-modified-since is also specified, the timeline info will return when unique id is not the specified one even if it is not modified. /// Same effect as If-Modified-Since header and take precedence than it. /// If specified, will return 304 if not modified. - /// Succeeded to get timeline info. - /// Timeline not change. - /// Timeline does not exist. + /// The timeline info. [HttpGet("timelines/{name}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status304NotModified)] @@ -171,14 +168,12 @@ namespace Timeline.Controllers } /// - /// Get posts of a timeline. You need to have permission. + /// Get posts of a timeline. /// /// The name of the timeline. /// If set, only posts modified since the time will return. /// If set to true, deleted post will also return. - /// Succeeded to get posts. - /// You have no permission. - /// The timeline does not exist. + /// The post list. [HttpGet("timelines/{name}/posts")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status403Forbidden)] @@ -197,16 +192,12 @@ namespace Timeline.Controllers } /// - /// Get the data of a post. Usually a image post. You need to have permission. + /// Get the data of a post. Usually a image post. /// /// Timeline name. /// The id of the post. /// If-None-Match header. - /// Succeeded to get data. - /// Data not changed. - /// Error code is 11040502 if post has no data. - /// You have no permission. - /// Timeline or post does not exist. + /// The data. [HttpGet("timelines/{name}/posts/{id}/data")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] @@ -240,15 +231,11 @@ namespace Timeline.Controllers } /// - /// Create a new post. You need to have permission. + /// Create a new post. /// /// Timeline name. /// /// Info of new post. - /// Succeeded to create post and return info of new post. - /// Body model is invalid. - /// You have not logged in. - /// You have no permission. [HttpPost("timelines/{name}/posts")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -316,9 +303,7 @@ namespace Timeline.Controllers /// /// Timeline name. /// Post id. - /// Succeeded to delete post. Or post does not exist. - /// You have not logged in. - /// You have no permission. + /// Info of deletion. [HttpDelete("timelines/{name}/posts/{id}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -347,9 +332,6 @@ namespace Timeline.Controllers /// Timeline name. /// /// The new info. - /// Succeeded to change properties of timeline. Return the new info. - /// You have not logged in. - /// You have no permission. [HttpPatch("timelines/{name}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -372,10 +354,6 @@ namespace Timeline.Controllers /// /// Timeline name. /// The new member's username. - /// Succeeded. - /// User does not exist. - /// You have not logged in. - /// You have no permission. [HttpPut("timelines/{name}/members/{member}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -405,9 +383,6 @@ namespace Timeline.Controllers /// /// Timeline name. /// The member's username. - /// Succeeded. Or the user is not a member. - /// You have not logged in. - /// You have no permission. [HttpDelete("timelines/{name}/members/{member}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -436,9 +411,6 @@ namespace Timeline.Controllers /// /// /// Info of new timeline. - /// Succeeded and return info of new timeline. - /// Timeline name is conflict. - /// You have not logged in. [HttpPost("timelines")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] @@ -464,9 +436,7 @@ namespace Timeline.Controllers /// Delete a timeline. /// /// Timeline name. - /// Succeeded. Or timeline does not exist. - /// You have not logged in. - /// You have no permission. + /// Info of deletion. [HttpDelete("timelines/{name}")] [Authorize] [ProducesResponseType(StatusCodes.Status200OK)] diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index 7792b318..8f2ca600 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -40,11 +40,10 @@ namespace Timeline.Controllers /// /// Create a new token for a user. /// - /// Succeed to create token. - /// Error code is 11010101 if user does not exist or password is wrong. + /// Result of token creation. [HttpPost("create")] [AllowAnonymous] - [ProducesResponseType(typeof(CreateTokenResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task> Create([FromBody] CreateTokenRequest request) { @@ -91,11 +90,10 @@ namespace Timeline.Controllers /// /// Verify a token. /// - /// Token is valid. - /// Error code is 11010201 if token is of bad format (it may not be created by this server). Error code is 11010202 if user does not exist. Error code is 11010203 if token is of old version (user may have changed password). Error code is 11010204 if token is expired. + /// Result of token verification. [HttpPost("verify")] [AllowAnonymous] - [ProducesResponseType(typeof(VerifyTokenResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task> Verify([FromBody] VerifyTokenRequest request) { diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index 3d3bc983..52e87df2 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -42,9 +42,7 @@ namespace Timeline.Controllers /// /// Username of the user to get avatar of. /// If-None-Match header. - /// Succeeded to get the avatar. - /// The avatar does not change. - /// The user does not exist. + /// Avatar data. [HttpGet("users/{username}/avatar")] [ProducesResponseType(typeof(byte[]), StatusCodes.Status200OK)] [ProducesResponseType(typeof(void), StatusCodes.Status304NotModified)] @@ -74,10 +72,6 @@ namespace Timeline.Controllers /// Set avatar of a user. You have to be administrator to change other's. /// /// Username of the user to set avatar of. - /// Succeeded to set avatar. - /// Error code is 10010001 if user does not exist. Or avatar is of bad format. - /// You have not logged in. - /// You are not administrator. [HttpPut("users/{username}/avatar")] [Authorize] [RequireContentType, RequireContentLength] diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index fa2d37d8..02c09aab 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -43,9 +43,9 @@ namespace Timeline.Controllers /// /// Get all users. /// - /// The user list. + /// All user list. [HttpGet("users")] - [ProducesResponseType(typeof(UserInfo[]), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] public async Task> List() { var users = await _userService.GetUsers(); @@ -54,12 +54,13 @@ namespace Timeline.Controllers } /// - /// Get a user info. + /// Get a user's info. /// /// Username of the user. - /// The user info. + /// User info. [HttpGet("users/{username}")] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task> Get([FromRoute][Username] string username) { try @@ -75,16 +76,14 @@ namespace Timeline.Controllers } /// - /// Change a user's property. You have to be administrator in some condition. + /// Change a user's property. /// /// /// Username of the user to change. - /// Succeed to change the user and return the new user info. - /// You have not logged in. - /// You are not administrator. - /// The user to change does not exist. + /// The new user info. [HttpPatch("users/{username}"), Authorize] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -134,11 +133,9 @@ namespace Timeline.Controllers /// Delete a user and all his related data. You have to be administrator. /// /// Username of the user to delete. - /// Succeeded to delete or the user does not exist. - /// You have not logged in. - /// You are not administrator. + /// Info of deletion. [HttpDelete("users/{username}"), AdminAuthorize] - [ProducesResponseType(typeof(CommonDeleteResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task> Delete([FromRoute][Username] string username) @@ -153,12 +150,9 @@ namespace Timeline.Controllers /// /// Create a new user. You have to be administrator. /// - /// Succeeded to create a new user and return his user info. - /// Error code is 11020101 if a user with given username already exists. - /// You have not logged in. - /// You are not administrator. + /// The new user's info. [HttpPost("userop/createuser"), AdminAuthorize] - [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] @@ -178,11 +172,8 @@ namespace Timeline.Controllers /// /// Change password with old password. /// - /// Succeeded to change password. - /// Error code is 11020201 if old password is wrong. - /// You have not logged in. [HttpPost("userop/changepassword"), Authorize] - [ProducesResponseType(typeof(void), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] public async Task ChangePassword([FromBody] ChangePasswordRequest request) -- cgit v1.2.3