作者 yangfu

业务表同步

@@ -22,7 +22,8 @@ STARROCKS_DB_NAME = character_library @@ -22,7 +22,8 @@ STARROCKS_DB_NAME = character_library
22 STARROCKS_USER = root 22 STARROCKS_USER = root
23 STARROCKS_PASSWORD = eagle1010 23 STARROCKS_PASSWORD = eagle1010
24 STARROCKS_HOST = 220.250.41.79 24 STARROCKS_HOST = 220.250.41.79
25 -STARROCKS_PORT = 9030 25 +#9030
  26 +STARROCKS_PORT = 9430
26 27
27 BLACK_LIST_USER = 0 28 BLACK_LIST_USER = 0
28 BLACK_LIST_COMPANY = 1612991734952759296 29 BLACK_LIST_COMPANY = 1612991734952759296
@@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib" 11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib"
12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" 12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
  13 + "strings"
13 ) 14 )
14 15
15 func (tableService *TableService) ShowBusinessDatabases(ctx *domain.Context, cmd *query.ShowBusinessDatabasesRequest) (interface{}, error) { 16 func (tableService *TableService) ShowBusinessDatabases(ctx *domain.Context, cmd *query.ShowBusinessDatabasesRequest) (interface{}, error) {
@@ -160,8 +161,13 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd @@ -160,8 +161,13 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
160 var ( 161 var (
161 fields = make([]*domain.Field, 0) 162 fields = make([]*domain.Field, 0)
162 mainTable *domain.Table 163 mainTable *domain.Table
  164 + hasPkField bool
163 ) 165 )
164 for i, f := range cmd.Fields { 166 for i, f := range cmd.Fields {
  167 + if strings.ToLower(f.FieldEnName) == "id" {
  168 + hasPkField = true
  169 + continue
  170 + }
165 fields = append(fields, &domain.Field{ 171 fields = append(fields, &domain.Field{
166 Index: i + 1, 172 Index: i + 1,
167 Name: f.FieldZhName, 173 Name: f.FieldZhName,
@@ -170,6 +176,9 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd @@ -170,6 +176,9 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd
170 Flag: domain.MainTableField, 176 Flag: domain.MainTableField,
171 }) 177 })
172 } 178 }
  179 + if !hasPkField {
  180 + return nil, fmt.Errorf("业务表未包含字段 `id`")
  181 + }
173 mainTable = domainService.NewTable(domain.MainTable, cmd.TableName, fields, 0). 182 mainTable = domainService.NewTable(domain.MainTable, cmd.TableName, fields, 0).
174 WithContext(ctx). 183 WithContext(ctx).
175 WithPrefix(domain.MainTable.ToString()).ApplyDefaultModule() 184 WithPrefix(domain.MainTable.ToString()).ApplyDefaultModule()