作者 yangfu

业务表同步

1 package command 1 package command
2 2
3 type GenerateBusinessTableRequest struct { 3 type GenerateBusinessTableRequest struct {
4 - TableName string `json:"mainTableName"`  
5 - TableFullName string `json:"tableFullName"` 4 + TableName string `json:"tableRemarkName"`
  5 + TableFullName string `json:"tableSqlName"`
6 Fields []FieldSchemas `json:"fields"` 6 Fields []FieldSchemas `json:"fields"`
7 } 7 }
@@ -110,6 +110,14 @@ func (table *Table) WithParentId(parentId int) *Table { @@ -110,6 +110,14 @@ func (table *Table) WithParentId(parentId int) *Table {
110 return table 110 return table
111 } 111 }
112 112
  113 +func (table *Table) WithTableInfo(t *Table) *Table {
  114 + if t.TableInfo == nil {
  115 + return table
  116 + }
  117 + table.TableInfo.TableFrom = t.TableInfo.TableFrom
  118 + return table
  119 +}
  120 +
113 func (table *Table) WithDataFieldIndex(dataFieldIndex int) *Table { 121 func (table *Table) WithDataFieldIndex(dataFieldIndex int) *Table {
114 table.DataFieldIndex = dataFieldIndex 122 table.DataFieldIndex = dataFieldIndex
115 return table 123 return table
@@ -45,7 +45,7 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl @@ -45,7 +45,7 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
45 fields = MappingFieldsV2(mainTable, fields) 45 fields = MappingFieldsV2(mainTable, fields)
46 dataFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.MainTableField}) 46 dataFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.MainTableField})
47 manualFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.ManualField}) 47 manualFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.ManualField})
48 - table := NewTable(domain.SubTable, name, fields, mainTable.RowCount).WithContext(ctx).WithPrefix(string(domain.SubTable)) 48 + table := NewTable(domain.SubTable, name, fields, mainTable.RowCount).WithContext(ctx).WithPrefix(string(domain.SubTable)).WithTableInfo(mainTable)
49 table.DataFieldIndex = mainTable.DataFieldIndex 49 table.DataFieldIndex = mainTable.DataFieldIndex
50 table.DataFields = dataFields 50 table.DataFields = dataFields
51 table.ManualFields = manualFields 51 table.ManualFields = manualFields
@@ -55,7 +55,8 @@ func (ptr *CopyDataTableService) CopyTable(ctx *domain.Context, tableId int, tab @@ -55,7 +55,8 @@ func (ptr *CopyDataTableService) CopyTable(ctx *domain.Context, tableId int, tab
55 WithContext(ctx). 55 WithContext(ctx).
56 WithParentId(table.TableId). 56 WithParentId(table.TableId).
57 WithDataFieldIndex(table.DataFieldIndex). 57 WithDataFieldIndex(table.DataFieldIndex).
58 - WithPrefix(domain.SideTable.ToString()) 58 + WithPrefix(domain.SideTable.ToString()).
  59 + WithTableInfo(table)
59 if sideTable, err = tableRepository.Save(sideTable); err != nil { 60 if sideTable, err = tableRepository.Save(sideTable); err != nil {
60 return nil, err 61 return nil, err
61 } 62 }