5 files changed
+21
-14
No files matched your search
+18
-10
@@ -81,10 +81,26 @@ func GetSysTables(c *gin.Context) {
|
|||||||
// @Router /api/v1/sys/tables/info [post]
|
// @Router /api/v1/sys/tables/info [post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func InsertSysTable(c *gin.Context) {
|
func InsertSysTable(c *gin.Context) {
|
||||||
|
|
||||||
|
tablesList := strings.Split(c.Request.FormValue("tables"), ",")
|
||||||
|
for i := 0; i < len(tablesList); i++ {
|
||||||
|
|
||||||
|
data, err := genTableInit(tablesList, i, c)
|
||||||
|
|
||||||
|
_, err = data.Create()
|
||||||
|
tools2.HasError(err, "", -1)
|
||||||
|
}
|
||||||
|
var res app.Response
|
||||||
|
res.Msg = "添加成功!"
|
||||||
|
c.JSON(http.StatusOK, res.ReturnOK())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func genTableInit(tablesList []string, i int, c *gin.Context) (tools.SysTables, error) {
|
||||||
var data tools.SysTables
|
var data tools.SysTables
|
||||||
var dbTable tools.DBTables
|
var dbTable tools.DBTables
|
||||||
var dbColumn tools.DBColumns
|
var dbColumn tools.DBColumns
|
||||||
data.TBName = c.Request.FormValue("tables")
|
data.TBName = tablesList[i]
|
||||||
data.CreateBy = tools2.GetUserIdStr(c)
|
data.CreateBy = tools2.GetUserIdStr(c)
|
||||||
|
|
||||||
dbTable.TableName = data.TBName
|
dbTable.TableName = data.TBName
|
||||||
@@ -161,15 +177,7 @@ func InsertSysTable(c *gin.Context) {
|
|||||||
|
|
||||||
data.Columns = append(data.Columns, column)
|
data.Columns = append(data.Columns, column)
|
||||||
}
|
}
|
||||||
|
return data, err
|
||||||
result, err := data.Create()
|
|
||||||
tools2.HasError(err, "", -1)
|
|
||||||
|
|
||||||
var res app.Response
|
|
||||||
res.Data = result
|
|
||||||
res.Msg = "添加成功!"
|
|
||||||
c.JSON(http.StatusOK, res.ReturnOK())
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary 修改表结构
|
// @Summary 修改表结构
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
settings:
|
settings:
|
||||||
application:
|
application:
|
||||||
mode: dev # dev开发环境 test测试环境 prod线上环境
|
mode: dev # dev开发环境 test测试环境 prod线上环境
|
||||||
demomsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600"
|
|
||||||
host: 0.0.0.0
|
host: 0.0.0.0
|
||||||
name: testApp
|
name: testApp
|
||||||
port: 8000
|
port: 8000
|
||||||
|
|||||||
+1
-2
@@ -10,10 +10,9 @@ import (
|
|||||||
func AuthInit() (*jwt.GinJWTMiddleware, error) {
|
func AuthInit() (*jwt.GinJWTMiddleware, error) {
|
||||||
return jwt.New(&jwt.GinJWTMiddleware{
|
return jwt.New(&jwt.GinJWTMiddleware{
|
||||||
Realm: "test zone",
|
Realm: "test zone",
|
||||||
Key: []byte("secret key"),
|
Key: []byte(config.ApplicationConfig.JwtSecret),
|
||||||
Timeout: time.Hour,
|
Timeout: time.Hour,
|
||||||
MaxRefresh: time.Hour,
|
MaxRefresh: time.Hour,
|
||||||
IdentityKey: config.ApplicationConfig.JwtSecret,
|
|
||||||
PayloadFunc: handler.PayloadFunc,
|
PayloadFunc: handler.PayloadFunc,
|
||||||
IdentityHandler: handler.IdentityHandler,
|
IdentityHandler: handler.IdentityHandler,
|
||||||
Authenticator: handler.Authenticator,
|
Authenticator: handler.Authenticator,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error)
|
|||||||
var doc []DBTables
|
var doc []DBTables
|
||||||
|
|
||||||
table := orm.Eloquent.Select("*").Table("information_schema.tables")
|
table := orm.Eloquent.Select("*").Table("information_schema.tables")
|
||||||
|
table = table.Where("TABLE_NAME not in (select table_name from "+config2.DatabaseConfig.Name+".sys_tables) ")
|
||||||
table = table.Where("table_schema= ? ", config2.DatabaseConfig.Name)
|
table = table.Where("table_schema= ? ", config2.DatabaseConfig.Name)
|
||||||
|
|
||||||
if e.TableName != "" {
|
if e.TableName != "" {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ func (e *SysTables) Delete() (success bool, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *SysTables) BatchDelete(id []int) (Result bool, err error) {
|
func (e *SysTables) BatchDelete(id []int) (Result bool, err error) {
|
||||||
if err = orm.Eloquent.Table(e.TableName()).Where(" table_id in (?)", id).Delete(&SysColumns{}).Error; err != nil {
|
if err = orm.Eloquent.Unscoped().Table(e.TableName()).Where(" table_id in (?)", id).Delete(&SysColumns{}).Error; err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Result = true
|
Result = true
|
||||||
|
|||||||
Reference in new issue
Block a user