diff options
author | crupest <crupest@outlook.com> | 2021-04-30 17:53:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-30 17:53:40 +0800 |
commit | 5bd826d47c30f6e6ac6eded4fefb99f26786c3bc (patch) | |
tree | c9ad0a4706c70d3678945e6bce74b4a5da2a7eb5 /BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs | |
parent | 5d28f5d0eb352369c73e3908c7d00d868676c304 (diff) | |
download | timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.tar.gz timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.tar.bz2 timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs b/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs index 76a8b7ae..a3da73fa 100644 --- a/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs +++ b/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs @@ -1,11 +1,22 @@ -using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using Timeline.Models.Http;
namespace Timeline.Controllers
{
public static class ActionResultControllerExtensions
{
- public static BadRequestObjectResult BadRequestWithCodeAndMessage(this ControllerBase controller, int code, string message)
+ public static ObjectResult StatusCodeWithCommonResponse(this ControllerBase controller, int statusCode, int code, string message)
+ {
+ return controller.StatusCode(statusCode, new CommonResponse(code, message));
+ }
+
+ public static ObjectResult ForbidWithMessage(this ControllerBase controller, string? message = null)
+ {
+ return controller.StatusCode(StatusCodes.Status403Forbidden, new CommonResponse(ErrorCodes.Common.Forbid, message ?? Resource.MessageForbid));
+ }
+
+ public static BadRequestObjectResult BadRequestWithCommonResponse(this ControllerBase controller, int code, string message)
{
return controller.BadRequest(new CommonResponse(code, message));
}
|