mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-20 17:57:54 +00:00
修改数据表结构功能
This commit is contained in:
@@ -13,6 +13,7 @@ type SysColumns struct {
|
||||
ColumnType string `gorm:"column:column_type" json:"columnType"`
|
||||
GoType string `gorm:"column:go_type" json:"goType"`
|
||||
GoField string `gorm:"column:go_field" json:"goField"`
|
||||
JsonField string `gorm:"column:json_field" json:"jsonField"`
|
||||
IsPk string `gorm:"column:is_pk" json:"isPk"`
|
||||
IsIncrement string `gorm:"column:is_increment" json:"isIncrement"`
|
||||
IsRequired string `gorm:"column:is_required" json:"isRequired"`
|
||||
@@ -65,3 +66,19 @@ func (e *SysColumns) Create() (SysColumns, error) {
|
||||
doc = *e
|
||||
return doc, nil
|
||||
}
|
||||
|
||||
func (e *SysColumns) Update() (update SysColumns, err error) {
|
||||
e.UpdateTime = utils.GetCurrntTime()
|
||||
if err = orm.Eloquent.Table("sys_columns").First(&update, e.ColumnId).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//参数1:是要修改的数据
|
||||
//参数2:是修改的数据
|
||||
if err = orm.Eloquent.Table("sys_columns").Model(&update).Updates(&e).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,16 @@ type SysTables struct {
|
||||
UpdateBy string `gorm:"column:update_By" json:"updateBy"`
|
||||
UpdateTime string `gorm:"column:update_time" json:"updateTime"`
|
||||
DataScope string `gorm:"-" json:"dataScope"`
|
||||
Params string `gorm:"-" json:"params"`
|
||||
Params Params `gorm:"-" json:"params"`
|
||||
Columns []SysColumns `gorm:"-" json:"columns"`
|
||||
}
|
||||
|
||||
type Params struct {
|
||||
TreeCode string `gorm:"-" json:"treeCode"`
|
||||
TreeParentCode string `gorm:"-" json:"treeParentCode"`
|
||||
TreeName string `gorm:"-" json:"treeName"`
|
||||
}
|
||||
|
||||
func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, error) {
|
||||
var doc []SysTables
|
||||
|
||||
@@ -120,6 +126,10 @@ func (e *SysTables) Update() (update SysTables, err error) {
|
||||
if err = orm.Eloquent.Table("sys_tables").Model(&update).Updates(&e).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for i:=0;i< len(e.Columns);i++ {
|
||||
_, _ = e.Columns[i].Update()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user