forked from go-admin-team/go-admin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e149589
commit 65dbf58
Showing
13 changed files
with
497 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ main.exe | |
temp/logs/log.txt | ||
vendor | ||
config/settings.dev.yml | ||
temp/logs/log.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package tools | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"go-admin/models" | ||
"go-admin/models/tools" | ||
"go-admin/pkg" | ||
"net/http" | ||
) | ||
|
||
// @Summary 分页列表数据 / page list data | ||
// @Description 数据库表列分页列表 / database table column page list | ||
// @Tags 工具 / Tools | ||
// @Param tableName query string false "tableName / 数据表名称" | ||
// @Param pageSize query int false "pageSize / 页条数" | ||
// @Param pageIndex query int false "pageIndex / 页码" | ||
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" | ||
// @Router /api/v1/db/columns/page [get] | ||
func GetDBColumnList(c *gin.Context) { | ||
var data tools.DBColumns | ||
var err error | ||
var pageSize = 10 | ||
var pageIndex = 1 | ||
|
||
if size := c.Request.FormValue("pageSize"); size != "" { | ||
pageSize = pkg.StrToInt(err, size) | ||
} | ||
|
||
if index := c.Request.FormValue("pageIndex"); index != "" { | ||
pageIndex = pkg.StrToInt(err, index) | ||
} | ||
|
||
data.TableName = c.Request.FormValue("tableName") | ||
pkg.Assert(data.TableName=="","table name cannot be empty!",500) | ||
result, count, err := data.GetPage(pageSize, pageIndex) | ||
pkg.AssertErr(err, "", -1) | ||
|
||
var mp = make(map[string]interface{}, 3) | ||
mp["list"] = result | ||
mp["count"] = count | ||
mp["pageIndex"] = pageIndex | ||
mp["pageIndex"] = pageSize | ||
|
||
var res models.Response | ||
res.Data = mp | ||
|
||
c.JSON(http.StatusOK, res.ReturnOK()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tools | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"go-admin/models" | ||
"go-admin/models/tools" | ||
"go-admin/pkg" | ||
"net/http" | ||
) | ||
|
||
// @Summary 分页列表数据 / page list data | ||
// @Description 数据库表分页列表 / database table page list | ||
// @Tags 工具 / Tools | ||
// @Param tableName query string false "tableName / 数据表名称" | ||
// @Param pageSize query int false "pageSize / 页条数" | ||
// @Param pageIndex query int false "pageIndex / 页码" | ||
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" | ||
// @Router /api/v1/db/tables/page [get] | ||
func GetDBTableList(c *gin.Context) { | ||
var data tools.DBTables | ||
var err error | ||
var pageSize = 10 | ||
var pageIndex = 1 | ||
|
||
if size := c.Request.FormValue("pageSize"); size != "" { | ||
pageSize = pkg.StrToInt(err, size) | ||
} | ||
|
||
if index := c.Request.FormValue("pageIndex"); index != "" { | ||
pageIndex = pkg.StrToInt(err, index) | ||
} | ||
|
||
data.TableName = c.Request.FormValue("tableName") | ||
result, count, err := data.GetPage(pageSize, pageIndex) | ||
pkg.AssertErr(err, "", -1) | ||
|
||
var mp = make(map[string]interface{}, 3) | ||
mp["list"] = result | ||
mp["count"] = count | ||
mp["pageIndex"] = pageIndex | ||
mp["pageIndex"] = pageSize | ||
|
||
var res models.Response | ||
res.Data = mp | ||
|
||
c.JSON(http.StatusOK, res.ReturnOK()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tools | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"go-admin/models" | ||
"go-admin/models/tools" | ||
"go-admin/pkg" | ||
"net/http" | ||
) | ||
|
||
// @Summary 分页列表数据 / page list data | ||
// @Description 生成表分页列表 / gen table page list | ||
// @Tags 工具 - Tools / 生成表 - Gen Table | ||
// @Param tableName query string false "tableName / 数据表名称" | ||
// @Param pageSize query int false "pageSize / 页条数" | ||
// @Param pageIndex query int false "pageIndex / 页码" | ||
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" | ||
// @Router /api/v1/sys/tables/page [get] | ||
func GetSysTableList(c *gin.Context) { | ||
var data tools.SysTables | ||
var err error | ||
var pageSize = 10 | ||
var pageIndex = 1 | ||
|
||
if size := c.Request.FormValue("pageSize"); size != "" { | ||
pageSize = pkg.StrToInt(err, size) | ||
} | ||
|
||
if index := c.Request.FormValue("pageIndex"); index != "" { | ||
pageIndex = pkg.StrToInt(err, index) | ||
} | ||
|
||
data.TableName = c.Request.FormValue("tableName") | ||
result, count, err := data.GetPage(pageSize, pageIndex) | ||
pkg.AssertErr(err, "", -1) | ||
|
||
var mp = make(map[string]interface{}, 3) | ||
mp["list"] = result | ||
mp["count"] = count | ||
mp["pageIndex"] = pageIndex | ||
mp["pageIndex"] = pageSize | ||
|
||
var res models.Response | ||
res.Data = mp | ||
|
||
c.JSON(http.StatusOK, res.ReturnOK()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.