api层写法统一
This commit is contained in:
1 parent
fa30b8db95
commit
9bf9330410
40 files changed
+430
-316
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||
@@ -15,7 +16,6 @@ import (
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/models/system"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/common/apis"
|
||||
)
|
||||
|
||||
// LoggerToFile 日志记录到文件
|
||||
@@ -25,7 +25,7 @@ func LoggerToFile() gin.HandlerFunc {
|
||||
if c.Request.Method == http.MethodOptions {
|
||||
return
|
||||
}
|
||||
log := apis.GetRequestLogger(c)
|
||||
log := api.GetRequestLogger(c)
|
||||
// 开始时间
|
||||
startTime := time.Now()
|
||||
// 处理请求
|
||||
@@ -79,11 +79,11 @@ func LoggerToFile() gin.HandlerFunc {
|
||||
|
||||
// SetDBOperLog 写入操作日志表 fixme 该方法后续即将弃用
|
||||
func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string, reqMethod string, latencyTime time.Duration, body string, result string, status int) {
|
||||
log := apis.GetRequestLogger(c)
|
||||
log := api.GetRequestLogger(c)
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
app.Error(c, http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
response.Error(c, http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user