作者 yangfu

业务表同步

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