作者 yangfu

业务表同步

package command
type GenerateBusinessTableRequest struct {
TableName string `json:"mainTableName"`
TableFullName string `json:"tableFullName"`
TableName string `json:"tableRemarkName"`
TableFullName string `json:"tableSqlName"`
Fields []FieldSchemas `json:"fields"`
}
... ...
... ... @@ -110,6 +110,14 @@ func (table *Table) WithParentId(parentId int) *Table {
return table
}
func (table *Table) WithTableInfo(t *Table) *Table {
if t.TableInfo == nil {
return table
}
table.TableInfo.TableFrom = t.TableInfo.TableFrom
return table
}
func (table *Table) WithDataFieldIndex(dataFieldIndex int) *Table {
table.DataFieldIndex = dataFieldIndex
return table
... ...
... ... @@ -45,7 +45,7 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
fields = MappingFieldsV2(mainTable, fields)
dataFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.MainTableField})
manualFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.ManualField})
table := NewTable(domain.SubTable, name, fields, mainTable.RowCount).WithContext(ctx).WithPrefix(string(domain.SubTable))
table := NewTable(domain.SubTable, name, fields, mainTable.RowCount).WithContext(ctx).WithPrefix(string(domain.SubTable)).WithTableInfo(mainTable)
table.DataFieldIndex = mainTable.DataFieldIndex
table.DataFields = dataFields
table.ManualFields = manualFields
... ...
... ... @@ -55,7 +55,8 @@ func (ptr *CopyDataTableService) CopyTable(ctx *domain.Context, tableId int, tab
WithContext(ctx).
WithParentId(table.TableId).
WithDataFieldIndex(table.DataFieldIndex).
WithPrefix(domain.SideTable.ToString())
WithPrefix(domain.SideTable.ToString()).
WithTableInfo(table)
if sideTable, err = tableRepository.Save(sideTable); err != nil {
return nil, err
}
... ...