feat: model type change
This commit is contained in:
1 parent
84a78d7b4f
commit
02cc68daea
20 files changed
+286
-257
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"github.com/jinzhu/gorm"
|
||||
orm "go-admin/global"
|
||||
"go-admin/tools"
|
||||
config2 "go-admin/tools/config"
|
||||
)
|
||||
|
||||
@@ -38,7 +39,6 @@ func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int, erro
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName)
|
||||
}
|
||||
|
||||
|
||||
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -51,15 +51,17 @@ func (e *DBColumns) GetList() ([]DBColumns, error) {
|
||||
var doc []DBColumns
|
||||
table := new(gorm.DB)
|
||||
|
||||
if e.TableName == "" {
|
||||
return nil, errors.New("table name cannot be empty!")
|
||||
}
|
||||
|
||||
if config2.DatabaseConfig.Driver == "mysql" {
|
||||
table = orm.Eloquent.Select("*").Table("information_schema.columns")
|
||||
table = table.Where("table_schema= ? ", config2.DatabaseConfig.DBName)
|
||||
|
||||
if e.TableName == "" {
|
||||
return nil, errors.New("table name cannot be empty!")
|
||||
}
|
||||
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName)
|
||||
} else {
|
||||
tools.Assert(true, "目前只支持mysql数据库", 500)
|
||||
}
|
||||
if err := table.Find(&doc).Error; err != nil {
|
||||
return doc, err
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"github.com/jinzhu/gorm"
|
||||
orm "go-admin/global"
|
||||
"go-admin/tools"
|
||||
config2 "go-admin/tools/config"
|
||||
)
|
||||
|
||||
@@ -33,16 +34,8 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error)
|
||||
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
} else if config2.DatabaseConfig.Driver == "sqlite3" {
|
||||
table = orm.Eloquent.Select("name as TABLE_NAME,name as ENGINE,name as TABLE_ROWS,name as TABLE_COLLATION,name as CREATE_TIME,name as UPDATE_TIME,name as TABLE_COMMENT ").Table("sqlite_master")
|
||||
table = table.Where("type = 'table' ")
|
||||
|
||||
if e.TableName != "" {
|
||||
table = table.Where("name = ?", e.TableName)
|
||||
}
|
||||
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
} else {
|
||||
tools.Assert(true, "目前只支持mysql数据库", 500)
|
||||
}
|
||||
|
||||
table.Count(&count)
|
||||
@@ -59,13 +52,8 @@ func (e *DBTables) Get() (DBTables, error) {
|
||||
return doc, errors.New("table name cannot be empty!")
|
||||
}
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName)
|
||||
} else if config2.DatabaseConfig.Driver == "sqlite3" {
|
||||
table = orm.Eloquent.Select("name as TABLE_NAME,name as ENGINE,name as TABLE_ROWS,name as TABLE_COLLATION,name as CREATE_TIME,name as UPDATE_TIME,name as TABLE_COMMENT ").Table("sqlite_master")
|
||||
table = table.Where("type = 'table' ")
|
||||
|
||||
if e.TableName != "" {
|
||||
table = table.Where("name = ?", e.TableName)
|
||||
}
|
||||
} else {
|
||||
tools.Assert(true, "目前只支持mysql数据库", 500)
|
||||
}
|
||||
if err := table.First(&doc).Error; err != nil {
|
||||
return doc, err
|
||||
|
||||
+30
-30
@@ -7,36 +7,36 @@ import (
|
||||
|
||||
type SysColumns struct {
|
||||
ColumnId int `gorm:"primary_key;auto_increment" json:"columnId"`
|
||||
TableId int `gorm:"type:int(11);" json:"tableId"`
|
||||
ColumnName string `gorm:"type:varchar(128);" json:"columnName"`
|
||||
ColumnComment string `gorm:"column:column_comment;type:varchar(128);" json:"columnComment"`
|
||||
ColumnType string `gorm:"column:column_type;type:varchar(128);" json:"columnType"`
|
||||
GoType string `gorm:"column:go_type;type:varchar(128);" json:"goType"`
|
||||
GoField string `gorm:"column:go_field;type:varchar(128);" json:"goField"`
|
||||
JsonField string `gorm:"column:json_field;type:varchar(128);" json:"jsonField"`
|
||||
IsPk string `gorm:"column:is_pk;type:char(4);" json:"isPk"`
|
||||
IsIncrement string `gorm:"column:is_increment;type:char(4);" json:"isIncrement"`
|
||||
IsRequired string `gorm:"column:is_required;type:char(4);" json:"isRequired"`
|
||||
IsInsert string `gorm:"column:is_insert;type:char(4);" json:"isInsert"`
|
||||
IsEdit string `gorm:"column:is_edit;type:char(4);" json:"isEdit"`
|
||||
IsList string `gorm:"column:is_list;type:char(4);" json:"isList"`
|
||||
IsQuery string `gorm:"column:is_query;type:char(4);" json:"isQuery"`
|
||||
QueryType string `gorm:"column:query_type;type:varchar(128);" json:"queryType"`
|
||||
HtmlType string `gorm:"column:html_type;type:varchar(128);" json:"htmlType"`
|
||||
DictType string `gorm:"column:dict_type;type:varchar(128);" json:"dictType"`
|
||||
Sort int `gorm:"column:sort;type:int(4);" json:"sort"`
|
||||
List string `gorm:"column:list;type:char(1);" json:"list"`
|
||||
Pk bool `gorm:"column:pk;type:char(1);" json:"pk"`
|
||||
Required bool `gorm:"column:required;type:char(1);" json:"required"`
|
||||
SuperColumn bool `gorm:"column:super_column;type:char(1);" json:"superColumn"`
|
||||
UsableColumn bool `gorm:"column:usable_column;type:char(1);" json:"usableColumn"`
|
||||
Increment bool `gorm:"column:increment;type:char(1);" json:"increment"`
|
||||
Insert bool `gorm:"column:insert;type:char(1);" json:"insert"`
|
||||
Edit bool `gorm:"column:edit;type:char(1);" json:"edit"`
|
||||
Query bool `gorm:"column:query;type:char(1);" json:"query"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);" json:"remark"`
|
||||
CreateBy string `gorm:"column:create_by;type:varchar(128);" json:"createBy"`
|
||||
UpdateBy string `gorm:"column:update_By;type:varchar(128);" json:"updateBy"`
|
||||
TableId int `gorm:"" json:"tableId"`
|
||||
ColumnName string `gorm:"size:128;" json:"columnName"`
|
||||
ColumnComment string `gorm:"column:column_comment;size:128;" json:"columnComment"`
|
||||
ColumnType string `gorm:"column:column_type;size:128;" json:"columnType"`
|
||||
GoType string `gorm:"column:go_type;size:128;" json:"goType"`
|
||||
GoField string `gorm:"column:go_field;size:128;" json:"goField"`
|
||||
JsonField string `gorm:"column:json_field;size:128;" json:"jsonField"`
|
||||
IsPk string `gorm:"column:is_pk;size:4;" json:"isPk"`
|
||||
IsIncrement string `gorm:"column:is_increment;size:4;" json:"isIncrement"`
|
||||
IsRequired string `gorm:"column:is_required;size:4;" json:"isRequired"`
|
||||
IsInsert string `gorm:"column:is_insert;size:4;" json:"isInsert"`
|
||||
IsEdit string `gorm:"column:is_edit;size:4;" json:"isEdit"`
|
||||
IsList string `gorm:"column:is_list;size:4;" json:"isList"`
|
||||
IsQuery string `gorm:"column:is_query;size:4;" json:"isQuery"`
|
||||
QueryType string `gorm:"column:query_type;size:128;" json:"queryType"`
|
||||
HtmlType string `gorm:"column:html_type;size:128;" json:"htmlType"`
|
||||
DictType string `gorm:"column:dict_type;size:128;" json:"dictType"`
|
||||
Sort int `gorm:"column:sort;" json:"sort"`
|
||||
List string `gorm:"column:list;size:1;" json:"list"`
|
||||
Pk bool `gorm:"column:pk;size:1;" json:"pk"`
|
||||
Required bool `gorm:"column:required;size:1;" json:"required"`
|
||||
SuperColumn bool `gorm:"column:super_column;size:1;" json:"superColumn"`
|
||||
UsableColumn bool `gorm:"column:usable_column;size:1;" json:"usableColumn"`
|
||||
Increment bool `gorm:"column:increment;size:1;" json:"increment"`
|
||||
Insert bool `gorm:"column:insert;size:1;" json:"insert"`
|
||||
Edit bool `gorm:"column:edit;size:1;" json:"edit"`
|
||||
Query bool `gorm:"column:query;size:1;" json:"query"`
|
||||
Remark string `gorm:"column:remark;size:255;" json:"remark"`
|
||||
CreateBy string `gorm:"column:create_by;size:128;" json:"createBy"`
|
||||
UpdateBy string `gorm:"column:update_By;size:128;" json:"updateBy"`
|
||||
|
||||
models.BaseModel
|
||||
}
|
||||
|
||||
+24
-24
@@ -7,30 +7,30 @@ import (
|
||||
|
||||
type SysTables struct {
|
||||
TableId int `gorm:"primary_key;auto_increment" json:"tableId"` //表编码
|
||||
TBName string `gorm:"column:table_name;type:varchar(255);" json:"tableName"` //表名称
|
||||
TableComment string `gorm:"type:varchar(255);" json:"tableComment"` //表备注
|
||||
ClassName string `gorm:"type:varchar(255);" json:"className"` //类名
|
||||
TplCategory string `gorm:"type:varchar(255);" json:"tplCategory"`
|
||||
PackageName string `gorm:"type:varchar(255);" json:"packageName"` //包名
|
||||
ModuleName string `gorm:"type:varchar(255);" json:"moduleName"` //模块名
|
||||
BusinessName string `gorm:"type:varchar(255);" json:"businessName"`
|
||||
FunctionName string `gorm:"type:varchar(255);" json:"functionName"` //功能名称
|
||||
FunctionAuthor string `gorm:"type:varchar(255);" json:"functionAuthor"` //功能作者
|
||||
PkColumn string `gorm:"type:varchar(255);" json:"pkColumn"`
|
||||
PkGoField string `gorm:"type:varchar(255);" json:"pkGoField"`
|
||||
PkJsonField string `gorm:"type:varchar(255);" json:"pkJsonField"`
|
||||
Options string `gorm:"type:varchar(255);" json:"options"`
|
||||
TreeCode string `gorm:"type:varchar(255);" json:"treeCode"`
|
||||
TreeParentCode string `gorm:"type:varchar(255);" json:"treeParentCode"`
|
||||
TreeName string `gorm:"type:varchar(255);" json:"treeName"`
|
||||
Tree bool `gorm:"type:char(1);" json:"tree"`
|
||||
Crud bool `gorm:"type:char(1);" json:"crud"`
|
||||
Remark string `gorm:"type:varchar(255);" json:"remark"`
|
||||
IsLogicalDelete string `gorm:"type:char(1);" json:"isLogicalDelete"`
|
||||
LogicalDelete bool `gorm:"type:char(1);" json:"logicalDelete"`
|
||||
LogicalDeleteColumn string `gorm:"type:varchar(128);" json:"logicalDeleteColumn"`
|
||||
CreateBy string `gorm:"type:varchar(128);" json:"createBy"`
|
||||
UpdateBy string `gorm:"type:varchar(128);" json:"updateBy"`
|
||||
TBName string `gorm:"column:table_name;size:255;" json:"tableName"` //表名称
|
||||
TableComment string `gorm:"size:255;" json:"tableComment"` //表备注
|
||||
ClassName string `gorm:"size:255;" json:"className"` //类名
|
||||
TplCategory string `gorm:"size:255;" json:"tplCategory"`
|
||||
PackageName string `gorm:"size:255;" json:"packageName"` //包名
|
||||
ModuleName string `gorm:"size:255;" json:"moduleName"` //模块名
|
||||
BusinessName string `gorm:"size:255;" json:"businessName"`
|
||||
FunctionName string `gorm:"size:255;" json:"functionName"` //功能名称
|
||||
FunctionAuthor string `gorm:"size:255;" json:"functionAuthor"` //功能作者
|
||||
PkColumn string `gorm:"size:255;" json:"pkColumn"`
|
||||
PkGoField string `gorm:"size:255;" json:"pkGoField"`
|
||||
PkJsonField string `gorm:"size:255;" json:"pkJsonField"`
|
||||
Options string `gorm:"size:255;" json:"options"`
|
||||
TreeCode string `gorm:"size:255;" json:"treeCode"`
|
||||
TreeParentCode string `gorm:"size:255;" json:"treeParentCode"`
|
||||
TreeName string `gorm:"size:255;" json:"treeName"`
|
||||
Tree bool `gorm:"size:1;" json:"tree"`
|
||||
Crud bool `gorm:"size:1;" json:"crud"`
|
||||
Remark string `gorm:"size:255;" json:"remark"`
|
||||
IsLogicalDelete string `gorm:"size:1;" json:"isLogicalDelete"`
|
||||
LogicalDelete bool `gorm:"size:1;" json:"logicalDelete"`
|
||||
LogicalDeleteColumn string `gorm:"size:128;" json:"logicalDeleteColumn"`
|
||||
CreateBy string `gorm:"size:128;" json:"createBy"`
|
||||
UpdateBy string `gorm:"size:128;" json:"updateBy"`
|
||||
DataScope string `gorm:"-" json:"dataScope"`
|
||||
Params Params `gorm:"-" json:"params"`
|
||||
Columns []SysColumns `gorm:"-" json:"columns"`
|
||||
|
||||
Reference in new issue
Block a user