作者 yangfu

业务表同步

... ... @@ -4,4 +4,6 @@ type GenerateBusinessTableRequest struct {
TableName string `json:"tableRemarkName"`
TableFullName string `json:"tableSqlName"`
Fields []FieldSchemas `json:"fields"`
ShowTableNameBy int `json:"showTableNameBy"` // 展示表名 0:原表名 1:表名备注
ShowTableFieldNameBy int `json:"showTableFieldNameBy"` // 字段名在字库的显示 0:字段原名 1:字段备注
}
... ...
... ... @@ -176,9 +176,13 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
hasPkField = true
continue
}
var filedName = ""
if cmd.ShowTableFieldNameBy == 0 {
filedName = f.FieldEnName
}
fields = append(fields, &domain.Field{
Index: i + 1,
Name: f.FieldZhName,
Name: filedName,
SQLName: f.FieldEnName,
SQLType: f.FieldType, //TODO:类型转换
Flag: domain.MainTableField,
... ... @@ -187,7 +191,11 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
if !hasPkField {
return nil, factory.FastError(fmt.Errorf("业务表未包含字段 `id`"))
}
mainTable = domainService.NewTable(domain.MainTable, cmd.TableName, fields, 0).
var tableName = cmd.TableName
if cmd.ShowTableNameBy == 0 {
tableName = cmd.TableFullName
}
mainTable = domainService.NewTable(domain.MainTable, tableName, fields, 0).
WithContext(ctx).
WithPrefix(domain.MainTable.ToString()).ApplyDefaultModule()
mainTable.SQLName = cmd.TableFullName
... ...