feat: 代码优化

This commit is contained in:
meilin.huang
2023-03-16 16:40:57 +08:00
parent 5f1aaa40d8
commit 110abc4ac7
28 changed files with 430 additions and 340 deletions

View File

@@ -6,6 +6,7 @@ import (
"mayfly-go/pkg/global"
"mayfly-go/pkg/model"
"net/http"
"runtime/debug"
"strconv"
"github.com/gin-gonic/gin"
@@ -66,12 +67,10 @@ func ErrorRes(g *gin.Context, err interface{}) {
g.JSON(http.StatusOK, model.Error(t))
case error:
g.JSON(http.StatusOK, model.ServerError())
global.Log.Error(t)
// panic(err)
global.Log.Errorf("%s\n%s", t.Error(), string(debug.Stack()))
case string:
g.JSON(http.StatusOK, model.ServerError())
global.Log.Error(t)
// panic(err)
global.Log.Errorf("%s\n%s", t, string(debug.Stack()))
default:
global.Log.Error(t)
}