Explorar el Código

新增应用异常编码,更新初始化数据

zhontai hace 2 años
padre
commit
455ecc1cb2

+ 7 - 7
src/hosts/ZhonTai.Host/InitData/Admin/ad_permission.json

@@ -18,7 +18,7 @@
         "type": 2,
         "viewId": 161227168428101,
         "path": "/platform/workbench",
-        "icon": "fa fa-line-chart",
+        "icon": "ele-Menu",
         "opened": true,
         "isKeepAlive": true,
         "isAffix": true,
@@ -34,7 +34,7 @@
         "type": 1,
         "path": "/platform/auth",
         "redirect": "/platform/auth/user",
-        "icon": "fa fa-lock",
+        "icon": "iconfont icon-quanxian",
         "opened": true,
         "isKeepAlive": true,
         "sort": 2,
@@ -291,7 +291,7 @@
             "viewId": 161227168444486,
             "name": "admin/permission",
             "path": "/platform/auth/permission",
-            "icon": "iconfont icon-quanxian",
+            "icon": "fa fa-lock",
             "opened": true,
             "isKeepAlive": true,
             "sort": 4,
@@ -725,7 +725,7 @@
             "viewId": 161227168444485,
             "name": "admin/view",
             "path": "/platform/system/view",
-            "icon": "ele-Menu",
+            "icon": "iconfont icon-zujian",
             "opened": true,
             "isKeepAlive": true,
             "sort": 5,
@@ -931,7 +931,7 @@
                 "type": 3,
                 "opened": true,
                 "isKeepAlive": true,
-                "sort": 9,
+                "sort": 8,
                 "description": "",
                 "enabled": true,
                 "childs": []
@@ -970,7 +970,7 @@
                 "type": 3,
                 "opened": true,
                 "isKeepAlive": true,
-                "sort": 11,
+                "sort": 10,
                 "description": "",
                 "enabled": true,
                 "childs": []
@@ -996,7 +996,7 @@
                 "type": 3,
                 "opened": true,
                 "isKeepAlive": true,
-                "sort": 10,
+                "sort": 9,
                 "description": "",
                 "enabled": true,
                 "childs": []

+ 3 - 3
src/hosts/ZhonTai.Host/InitData/Admin/ad_permission_api.json

@@ -330,7 +330,7 @@
     "apiId": 161227168231493
   },
   {
-    "id": 360711172304965,
+    "id": 363544618700869,
     "permissionId": 161227168813126,
     "apiId": 161227168231494
   },
@@ -355,7 +355,7 @@
     "apiId": 161227168235590
   },
   {
-    "id": 360711084900421,
+    "id": 363544652439621,
     "permissionId": 161227168829509,
     "apiId": 161227168235591
   },
@@ -365,7 +365,7 @@
     "apiId": 161227168239685
   },
   {
-    "id": 360711246549061,
+    "id": 363544634417221,
     "permissionId": 161227168833606,
     "apiId": 161227168239686
   },

+ 3 - 2
src/platform/ZhonTai.Admin/Core/Dto/ResultOutput.cs

@@ -107,10 +107,11 @@ public static partial class ResultOutput
     /// 系统异常
     /// </summary>
     /// <param name="msg">消息</param>
+    /// <param name="code">编码</param>
     /// <returns></returns>
-    public static AppException Exception(string msg = null)
+    public static AppException Exception(string msg = null, string code = null)
     {
-        return new AppException(msg);
+        return new AppException(msg, code);
     }
 
     /// <summary>

+ 19 - 0
src/platform/ZhonTai.Admin/Core/Exceptions/AppException.cs

@@ -8,6 +8,9 @@ namespace ZhonTai.Admin.Core.Exceptions;
 /// </summary>
 public class AppException : Exception
 {
+    public string AppMessage { get; set; }
+    public string AppCode { get; set; }
+
     public AppException()
     {
     }
@@ -20,12 +23,28 @@ public class AppException : Exception
     public AppException(string message)
         : base(message)
     {
+        AppMessage= message;
+    }
+
+    public AppException(string message, string code)
+     : base(message)
+    {
+        AppMessage= message;
+        AppCode= code;
     }
 
 
     public AppException(string message, Exception innerException)
         : base(message, innerException)
     {
+        AppMessage= message;
+    }
+
+    public AppException(string message, string code, Exception innerException)
+        : base(message, innerException)
+    {
+        AppMessage = message;
+        AppCode = code;
     }
 }
     

+ 1 - 1
src/platform/ZhonTai.Admin/Core/Helpers/UploadHelper.cs

@@ -77,7 +77,7 @@ public class UploadHelper
     /// <returns></returns>
     public async Task SaveAsync(IFormFile file, string filePath, CancellationToken cancellationToken = default)
     {
-        using (var stream = new FileStream(filePath, FileMode.Create))
+        using (var stream = File.Create(filePath))
         {
             await file.CopyToAsync(stream, cancellationToken);
         }

+ 5 - 2
src/platform/ZhonTai.Admin/Core/Middlewares/ExceptionMiddleware.cs

@@ -39,14 +39,17 @@ public class ExceptionMiddleware
         }
     }
 
-    private static Task HandleAppExceptionAsync(HttpContext context, Exception exception)
+    private static Task HandleAppExceptionAsync(HttpContext context, AppException appException)
     {
         context.Response.ContentType = "application/json";
         context.Response.StatusCode = (int)HttpStatusCode.OK;
 
         //_logger.LogError(exception, "");
 
-        return context.Response.WriteAsync(JsonHelper.Serialize(new ResultOutput<string>().NotOk(exception.Message)));
+        return context.Response.WriteAsync(JsonHelper.Serialize(new ResultOutput<string>()
+        {
+            Code = appException.AppCode
+        }.NotOk(appException.AppMessage)));
     }
 
     private Task HandleExceptionAsync(HttpContext context, Exception exception)

+ 2 - 1
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -1128,11 +1128,12 @@
             <param name="msg">消息</param>
             <returns></returns>
         </member>
-        <member name="M:ZhonTai.Admin.Core.Dto.ResultOutput.Exception(System.String)">
+        <member name="M:ZhonTai.Admin.Core.Dto.ResultOutput.Exception(System.String,System.String)">
             <summary>
             系统异常
             </summary>
             <param name="msg">消息</param>
+            <param name="code">编码</param>
             <returns></returns>
         </member>
         <member name="M:ZhonTai.Admin.Core.Dto.ResultOutput.Result``1(System.Boolean)">