|
@@ -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) {
|
|
@@ -158,10 +159,15 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd |
|
@@ -158,10 +159,15 @@ func (tableService *TableService) GenerateBusinessTable(ctx *domain.Context, cmd |
158
|
}
|
159
|
}
|
159
|
|
160
|
|
160
|
var (
|
161
|
var (
|
161
|
- fields = make([]*domain.Field, 0)
|
|
|
162
|
- mainTable *domain.Table
|
162
|
+ fields = make([]*domain.Field, 0)
|
|
|
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()
|