From dfa9fbf909486b65a42c46f1421ea7bf0e41016a Mon Sep 17 00:00:00 2001 From: xRain Date: Tue, 29 Dec 2020 17:39:06 +0800 Subject: [PATCH] fix controller Error return wrong message --- Communications/SimApiBaseResponse.cs | 5 ++++- Controllers/SimApiBaseController.cs | 6 +++--- README.md | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Communications/SimApiBaseResponse.cs b/Communications/SimApiBaseResponse.cs index 5a16652..773eef5 100644 --- a/Communications/SimApiBaseResponse.cs +++ b/Communications/SimApiBaseResponse.cs @@ -95,7 +95,7 @@ namespace SimApi.Communications { IgnoreReadOnlyProperties = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - Converters = { new JsonStringEnumConverter() } + Converters = {new JsonStringEnumConverter()} }); } } @@ -110,10 +110,13 @@ namespace SimApi.Communications /// 动态内容列表 /// public T List { get; set; } + //当前页码 public int Page { get; set; } + //每页条数 public int Count { get; set; } + //总计条数 public int Total { get; set; } } diff --git a/Controllers/SimApiBaseController.cs b/Controllers/SimApiBaseController.cs index 8c25af1..046aae4 100644 --- a/Controllers/SimApiBaseController.cs +++ b/Controllers/SimApiBaseController.cs @@ -47,7 +47,7 @@ namespace SimApi.Controllers /// 错误代码 /// 错误描述(若是常规错误,代码可自动带取描述) /// - protected static void Error(int code = 500, string message = "服务器错误") + protected static void Error(int code = 500, string message = "") { throw new SimApiException(code, message); } @@ -58,7 +58,7 @@ namespace SimApi.Controllers /// 检测条件 /// 错误代码 /// 错误描述 - protected static void ErrorWhen(bool condition, int code = 500, string message = "服务器错误") + protected static void ErrorWhen(bool condition, int code = 500, string message = "") { if (condition) { @@ -72,7 +72,7 @@ namespace SimApi.Controllers /// 检测条件 /// 错误代码 /// 错误描述 - protected static void ErrorWhenNull(object condition, int code = 404, string message = "资源不存在") + protected static void ErrorWhenNull(object condition, int code = 404, string message = "") { ErrorWhen(condition == null, code, message); } diff --git a/README.md b/README.md index b800e72..4e58da0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# YYApi 基于Asp.net Core 3的一个基础辅助包 +# YYApi 基于Asp.net Core 3/5的一个基础辅助包 ![CI](https://github.com/YY-Tech/YYApi/workflows/CI/badge.svg)