mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
调整log代码,兼容zap扩展支持fields
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"go-admin/common/apis"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/pkg/logger"
|
||||
tools2 "go-admin/tools"
|
||||
"go-admin/tools/app"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/db/columns/page [get]
|
||||
func GetDBColumnList(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
var data tools.DBColumns
|
||||
var err error
|
||||
var pageSize = 10
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"go-admin/common/apis"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/pkg/logger"
|
||||
tools2 "go-admin/tools"
|
||||
"go-admin/tools/app"
|
||||
"go-admin/tools/config"
|
||||
@@ -26,7 +26,7 @@ func GetDBTableList(c *gin.Context) {
|
||||
var err error
|
||||
var pageSize = 10
|
||||
var pageIndex = 1
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
if config.DatabaseConfig.Driver == "sqlite3" || config.DatabaseConfig.Driver == "postgres" {
|
||||
res.Msg = "对不起,sqlite3 或 postgres 不支持代码生成!"
|
||||
c.JSON(http.StatusOK, res.ReturnError(500))
|
||||
|
||||
@@ -2,6 +2,7 @@ package tools
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go-admin/common/apis"
|
||||
"net/http"
|
||||
"text/template"
|
||||
|
||||
@@ -9,14 +10,13 @@ import (
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/pkg/logger"
|
||||
tools2 "go-admin/tools"
|
||||
"go-admin/tools/app"
|
||||
"go-admin/tools/config"
|
||||
)
|
||||
|
||||
func Preview(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
table := tools.SysTables{}
|
||||
id, err := tools2.StringToInt(c.Param("tableId"))
|
||||
tools2.HasError(err, "", -1)
|
||||
@@ -69,7 +69,7 @@ func Preview(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GenCodeV3(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
table := tools.SysTables{}
|
||||
id, err := tools2.StringToInt(c.Param("tableId"))
|
||||
tools2.HasError(err, "", -1)
|
||||
@@ -192,7 +192,7 @@ func ActionsGenV3(tab tools.SysTables) {
|
||||
}
|
||||
|
||||
func GenMenuAndApi(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
|
||||
table := tools.SysTables{}
|
||||
timeNow := tools2.GetCurrentTime()
|
||||
@@ -433,4 +433,4 @@ func GenMenuAndApi(c *gin.Context) {
|
||||
ADelete.MenuId, err = ADelete.Create(db)
|
||||
|
||||
app.OK(c, "", "数据生成成功!")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"go-admin/pkg/logger"
|
||||
"go-admin/common/apis"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys/tables/page [get]
|
||||
func GetSysTableList(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
var data tools.SysTables
|
||||
var err error
|
||||
var pageSize = 10
|
||||
@@ -68,7 +68,7 @@ func GetSysTableList(c *gin.Context) {
|
||||
// @Router /api/v1/sys/tables/info/{tableId} [get]
|
||||
// @Security Bearer
|
||||
func GetSysTables(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
@@ -91,7 +91,7 @@ func GetSysTables(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetSysTablesInfo(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
@@ -116,7 +116,7 @@ func GetSysTablesInfo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetSysTablesTree(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
@@ -144,7 +144,7 @@ func GetSysTablesTree(c *gin.Context) {
|
||||
// @Router /api/v1/sys/tables/info [post]
|
||||
// @Security Bearer
|
||||
func InsertSysTable(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
@@ -246,7 +246,7 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool
|
||||
if strings.Contains(dbcolumn[i].ColumnType, "int") {
|
||||
if strings.Contains(dbcolumn[i].ColumnKey, "PR") {
|
||||
column.GoType = "int"
|
||||
} else {
|
||||
} else {
|
||||
column.GoType = "string"
|
||||
}
|
||||
column.HtmlType = "input"
|
||||
@@ -281,7 +281,7 @@ func UpdateSysTable(c *gin.Context) {
|
||||
err := c.Bind(&data)
|
||||
tools2.HasError(err, "数据解析失败", 500)
|
||||
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
@@ -307,7 +307,7 @@ func UpdateSysTable(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/sys/tables/info/{tableId} [delete]
|
||||
func DeleteSysTables(c *gin.Context) {
|
||||
log := logger.GetRequestLogger(c)
|
||||
log := apis.GetRequestLogger(c)
|
||||
db, err := tools2.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user