代码优化

This commit is contained in:
meilin.huang
2021-04-21 10:22:09 +08:00
parent ec1001d88b
commit d5fc1b6f52
14 changed files with 64 additions and 226 deletions

View File

@@ -11,6 +11,7 @@ import (
"mayfly-go/devops/db"
"mayfly-go/devops/models"
"strconv"
"strings"
"github.com/gin-gonic/gin"
)
@@ -18,15 +19,19 @@ import (
// @router /api/dbs [get]
func Dbs(rc *ctx.ReqCtx) {
m := new([]models.Db)
// querySetter := model.QuerySetter(new(models.Db))
rc.ResData = model.GetPage(ginx.GetPageParam(rc.GinCtx), m, new([]vo.SelectDataDbVO))
}
// @router /api/db/:dbId/select [get]
func SelectData(rc *ctx.ReqCtx) {
g := rc.GinCtx
selectSql := g.Query("selectSql")
// 去除前后空格及换行符
selectSql := strings.TrimFunc(g.Query("selectSql"), func(r rune) bool {
s := string(r)
return s == " " || s == "\n"
})
rc.ReqParam = selectSql
biz.NotEmpty(selectSql, "selectSql不能为空")
res, err := db.GetDbInstance(GetDbId(g)).SelectData(selectSql)
if err != nil {