作者 yangfu

业务表同步

... ... @@ -16,6 +16,9 @@ import (
func (tableService *TableService) ShowBusinessDatabases(ctx *domain.Context, cmd *query.ShowBusinessDatabasesRequest) (interface{}, error) {
byteCoreService := domainService.ByteCoreService{}
response, err := byteCoreService.ShowBusinessDatabases(bytelib.ReqShowBusinessDatabases{})
if err != nil {
return nil, factory.FastError(err)
}
return response, err
}
... ... @@ -25,6 +28,9 @@ func (tableService *TableService) ShowBusinessTables(ctx *domain.Context, cmd *q
DatabaseEnName: cmd.DatabaseEnName,
DatabaseType: cmd.DatabaseType,
})
if err != nil {
return nil, factory.FastError(err)
}
result := make([]map[string]interface{}, 0)
for _, t := range response.TableFullNames {
result = append(result, map[string]interface{}{
... ... @@ -43,7 +49,9 @@ func (tableService *TableService) QueryBusinessTable(ctx *domain.Context, cmd *q
PageNumber: cmd.PageNumber,
PageSize: cmd.PageSize,
})
if err != nil {
return nil, factory.FastError(err)
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -155,7 +163,7 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
duplicateTable, err := tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableName": cmd.TableName,
"tableTypes": []string{string(domain.MainTable), string(domain.SubTable), string(domain.SideTable)}})
if err == nil && duplicateTable != nil {
return nil, fmt.Errorf("表名称重复")
return nil, factory.FastError(fmt.Errorf("表名称重复"))
}
var (
... ... @@ -177,7 +185,7 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
})
}
if !hasPkField {
return nil, fmt.Errorf("业务表未包含字段 `id`")
return nil, factory.FastError(fmt.Errorf("业务表未包含字段 `id`"))
}
mainTable = domainService.NewTable(domain.MainTable, cmd.TableName, fields, 0).
WithContext(ctx).
... ...