qdy пре 3 недеља
родитељ
комит
d43adcee04
3 измењених фајлова са 217 додато и 427 уклоњено
  1. 39
    197
      sdk/configure/client.go
  2. 76
    69
      sdk/configure/test/example.go
  3. 102
    161
      sdk/configure/types.go

+ 39
- 197
sdk/configure/client.go Прегледај датотеку

@@ -154,137 +154,75 @@ func (c *Client) DeleteTable(ctx context.Context, tableID string) error {
154 154
 	return nil
155 155
 }
156 156
 
157
-// ListTableAliases 查询表别名字典列表
158
-func (c *Client) ListTableAliases(ctx context.Context, query *TableAliasQueryRequest) (*TableAliasList, error) {
159
-	endpoint := "/api/dic-table-alias/list"
157
+// BatchSaveTables 批量保存数据库表字典
158
+func (c *Client) BatchSaveTables(ctx context.Context, req *BatchSaveDicTablesRequest) error {
159
+	endpoint := "/api/dic-table/batch-save"
160 160
 
161
-	var result ResponseWrapper[[]DicTableAliasDB]
162
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, query, &result); err != nil {
163
-		return nil, err
161
+	var result ResponseWrapper[bool]
162
+	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
163
+		return err
164 164
 	}
165 165
 
166 166
 	if !result.Success {
167
-		return nil, NewClientError("list_table_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
167
+		return NewClientError("batch_save_tables", fmt.Sprintf("API error: %s", result.Error), nil)
168 168
 	}
169 169
 
170
-	return &TableAliasList{
171
-		TotalCount: result.TotalCount,
172
-		LastPage:   result.LastPage,
173
-		Data:       result.Data,
174
-	}, nil
170
+	return nil
175 171
 }
176 172
 
177
-// GetTableAlias 查询表别名字典详情
178
-func (c *Client) GetTableAlias(ctx context.Context, id string) (*TableAliasDetail, error) {
179
-	endpoint := fmt.Sprintf("/api/dic-table-alias/detail/%s", id)
173
+// BatchSyncTables 批量同步表字典
174
+func (c *Client) BatchSyncTables(ctx context.Context, req *BatchTableSyncRequest) (*BatchTableSyncResponse, error) {
175
+	endpoint := "/api/dic-table/batch-sync"
180 176
 
181
-	var result ResponseWrapper[TableAliasDetail]
182
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, nil, &result); err != nil {
177
+	var result ResponseWrapper[BatchTableSyncResponse]
178
+	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
183 179
 		return nil, err
184 180
 	}
185 181
 
186 182
 	if !result.Success {
187
-		if result.Error == "not found" || strings.Contains(result.Error, "不存在") {
188
-			return nil, ErrNotFound
189
-		}
190
-		return nil, NewClientError("get_table_alias", fmt.Sprintf("API error: %s", result.Error), nil)
183
+		return nil, NewClientError("batch_sync_tables", fmt.Sprintf("API error: %s", result.Error), nil)
191 184
 	}
192 185
 
193 186
 	return &result.Data, nil
194 187
 }
195 188
 
196
-// SaveTableAlias 创建或更新表别名字典
197
-func (c *Client) SaveTableAlias(ctx context.Context, req *TableAliasRequest) (*TableAliasDetail, error) {
198
-	endpoint := "/api/dic-table-alias/save"
189
+// BatchSyncAliases 批量同步别名
190
+func (c *Client) BatchSyncAliases(ctx context.Context, req *BatchAliasSyncRequest) (*BatchAliasSyncResponse, error) {
191
+	endpoint := "/api/alias/batch-sync"
199 192
 
200
-	var result ResponseWrapper[TableAliasDetail]
193
+	var result ResponseWrapper[BatchAliasSyncResponse]
201 194
 	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
202 195
 		return nil, err
203 196
 	}
204 197
 
205 198
 	if !result.Success {
206
-		return nil, NewClientError("save_table_alias", fmt.Sprintf("API error: %s", result.Error), nil)
199
+		return nil, NewClientError("batch_sync_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
207 200
 	}
208 201
 
209 202
 	return &result.Data, nil
210 203
 }
211 204
 
212
-// BatchSaveTableAliases 批量保存表别名字典
213
-func (c *Client) BatchSaveTableAliases(ctx context.Context, req *BatchTableAliasRequest) ([]TableAliasDetail, error) {
214
-	endpoint := "/api/dic-table-alias/batch-save"
205
+// SaveTableAlias 保存表别名字典
206
+func (c *Client) SaveTableAlias(ctx context.Context, req *TableAliasRequest) (*TableAliasResponse, error) {
207
+	endpoint := "/api/dic-table-alias/save"
215 208
 
216
-	var result ResponseWrapper[[]TableAliasDetail]
209
+	var result ResponseWrapper[TableAliasResponse]
217 210
 	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
218 211
 		return nil, err
219 212
 	}
220 213
 
221 214
 	if !result.Success {
222
-		return nil, NewClientError("batch_save_table_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
223
-	}
224
-
225
-	return result.Data, nil
226
-}
227
-
228
-// DeleteTableAlias 删除表别名字典
229
-func (c *Client) DeleteTableAlias(ctx context.Context, id string) error {
230
-	endpoint := fmt.Sprintf("/api/dic-table-alias/delete/%s", id)
231
-
232
-	var result ResponseWrapper[int64]
233
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, nil, &result); err != nil {
234
-		return err
235
-	}
236
-
237
-	if !result.Success {
238
-		return NewClientError("delete_table_alias", fmt.Sprintf("API error: %s", result.Error), nil)
239
-	}
240
-
241
-	return nil
242
-}
243
-
244
-// ListTableFieldAliases 查询字段别名字典列表
245
-func (c *Client) ListTableFieldAliases(ctx context.Context, query *TableFieldAliasQueryRequest) (*TableFieldAliasList, error) {
246
-	endpoint := "/api/dic-table-field-alias/list"
247
-
248
-	var result ResponseWrapper[[]DicTableFieldAliasDB]
249
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, query, &result); err != nil {
250
-		return nil, err
251
-	}
252
-
253
-	if !result.Success {
254
-		return nil, NewClientError("list_table_field_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
255
-	}
256
-
257
-	return &TableFieldAliasList{
258
-		TotalCount: result.TotalCount,
259
-		LastPage:   result.LastPage,
260
-		Data:       result.Data,
261
-	}, nil
262
-}
263
-
264
-// GetTableFieldAlias 查询字段别名字典详情
265
-func (c *Client) GetTableFieldAlias(ctx context.Context, id string) (*TableFieldAliasDetail, error) {
266
-	endpoint := fmt.Sprintf("/api/dic-table-field-alias/detail/%s", id)
267
-
268
-	var result ResponseWrapper[TableFieldAliasDetail]
269
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, nil, &result); err != nil {
270
-		return nil, err
271
-	}
272
-
273
-	if !result.Success {
274
-		if result.Error == "not found" || strings.Contains(result.Error, "不存在") {
275
-			return nil, ErrNotFound
276
-		}
277
-		return nil, NewClientError("get_table_field_alias", fmt.Sprintf("API error: %s", result.Error), nil)
215
+		return nil, NewClientError("save_table_alias", fmt.Sprintf("API error: %s", result.Error), nil)
278 216
 	}
279 217
 
280 218
 	return &result.Data, nil
281 219
 }
282 220
 
283
-// SaveTableFieldAlias 创建或更新字段别名字典
284
-func (c *Client) SaveTableFieldAlias(ctx context.Context, req *TableFieldAliasRequest) (*TableFieldAliasDetail, error) {
221
+// SaveTableFieldAlias 保存表字段别名字典
222
+func (c *Client) SaveTableFieldAlias(ctx context.Context, req *TableFieldAliasRequest) (*TableFieldAliasResponse, error) {
285 223
 	endpoint := "/api/dic-table-field-alias/save"
286 224
 
287
-	var result ResponseWrapper[TableFieldAliasDetail]
225
+	var result ResponseWrapper[TableFieldAliasResponse]
288 226
 	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
289 227
 		return nil, err
290 228
 	}
@@ -296,142 +234,46 @@ func (c *Client) SaveTableFieldAlias(ctx context.Context, req *TableFieldAliasRe
296 234
 	return &result.Data, nil
297 235
 }
298 236
 
299
-// BatchSaveTableFieldAliases 批量保存字段别名字典
300
-func (c *Client) BatchSaveTableFieldAliases(ctx context.Context, req *BatchTableFieldAliasRequest) ([]TableFieldAliasDetail, error) {
301
-	endpoint := "/api/dic-table-field-alias/batch-save"
302
-
303
-	var result ResponseWrapper[[]TableFieldAliasDetail]
304
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
305
-		return nil, err
306
-	}
307
-
308
-	if !result.Success {
309
-		return nil, NewClientError("batch_save_table_field_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
310
-	}
311
-
312
-	return result.Data, nil
313
-}
314
-
315
-// DeleteTableFieldAlias 删除字段别名字典
316
-func (c *Client) DeleteTableFieldAlias(ctx context.Context, id string) error {
317
-	endpoint := fmt.Sprintf("/api/dic-table-field-alias/delete/%s", id)
318
-
319
-	var result ResponseWrapper[int64]
320
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, nil, &result); err != nil {
321
-		return err
322
-	}
323
-
324
-	if !result.Success {
325
-		return NewClientError("delete_table_field_alias", fmt.Sprintf("API error: %s", result.Error), nil)
326
-	}
327
-
328
-	return nil
329
-}
330
-
331
-// ListTableAliasFlow 查询表别名字典流水列表
332
-func (c *Client) ListTableAliasFlow(ctx context.Context, query *TableAliasFlowQueryRequest) (*TableAliasFlowList, error) {
333
-	endpoint := "/api/dic-table-alias-flow/list"
237
+// ListTableAliases 查询表别名字典列表
238
+func (c *Client) ListTableAliases(ctx context.Context, query *TableAliasQueryRequest) (*TableAliasList, error) {
239
+	endpoint := "/api/dic-table-alias/list"
334 240
 
335
-	var result ResponseWrapper[[]DicTableAliasFlowDB]
241
+	var result ResponseWrapper[[]TableAliasResponse]
336 242
 	if err := c.doRequest(ctx, http.MethodPost, endpoint, query, &result); err != nil {
337 243
 		return nil, err
338 244
 	}
339 245
 
340 246
 	if !result.Success {
341
-		return nil, NewClientError("list_table_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
247
+		return nil, NewClientError("list_table_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
342 248
 	}
343 249
 
344
-	return &TableAliasFlowList{
250
+	return &TableAliasList{
345 251
 		TotalCount: result.TotalCount,
346 252
 		LastPage:   result.LastPage,
347 253
 		Data:       result.Data,
348 254
 	}, nil
349 255
 }
350 256
 
351
-// BatchSaveTableAliasFlow 批量保存表别名字典流水
352
-func (c *Client) BatchSaveTableAliasFlow(ctx context.Context, req *BatchTableAliasRequest) ([]DicTableAliasFlowDB, error) {
353
-	endpoint := "/api/dic-table-alias-flow/batch-save"
354
-
355
-	var result ResponseWrapper[[]DicTableAliasFlowDB]
356
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
357
-		return nil, err
358
-	}
359
-
360
-	if !result.Success {
361
-		return nil, NewClientError("batch_save_table_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
362
-	}
363
-
364
-	return result.Data, nil
365
-}
366
-
367
-// BatchApprovalTableAliasFlow 批量审批表别名字典流水
368
-func (c *Client) BatchApprovalTableAliasFlow(ctx context.Context, req *BatchApprovalFlowRequest) error {
369
-	endpoint := "/api/dic-table-alias-flow/batch-approval"
370
-
371
-	var result ResponseWrapper[int64]
372
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
373
-		return err
374
-	}
375
-
376
-	if !result.Success {
377
-		return NewClientError("batch_approval_table_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
378
-	}
379
-
380
-	return nil
381
-}
382
-
383
-// ListTableFieldAliasFlow 查询字段别名字典流水列表
384
-func (c *Client) ListTableFieldAliasFlow(ctx context.Context, query *TableFieldAliasFlowQueryRequest) (*TableFieldAliasFlowList, error) {
385
-	endpoint := "/api/dic-table-field-alias-flow/list"
257
+// ListTableFieldAliases 查询表字段别名字典列表
258
+func (c *Client) ListTableFieldAliases(ctx context.Context, query *TableFieldAliasQueryRequest) (*TableFieldAliasList, error) {
259
+	endpoint := "/api/dic-table-field-alias/list"
386 260
 
387
-	var result ResponseWrapper[[]DicTableFieldAliasFlowDB]
261
+	var result ResponseWrapper[[]TableFieldAliasResponse]
388 262
 	if err := c.doRequest(ctx, http.MethodPost, endpoint, query, &result); err != nil {
389 263
 		return nil, err
390 264
 	}
391 265
 
392 266
 	if !result.Success {
393
-		return nil, NewClientError("list_table_field_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
267
+		return nil, NewClientError("list_table_field_aliases", fmt.Sprintf("API error: %s", result.Error), nil)
394 268
 	}
395 269
 
396
-	return &TableFieldAliasFlowList{
270
+	return &TableFieldAliasList{
397 271
 		TotalCount: result.TotalCount,
398 272
 		LastPage:   result.LastPage,
399 273
 		Data:       result.Data,
400 274
 	}, nil
401 275
 }
402 276
 
403
-// BatchSaveTableFieldAliasFlow 批量保存字段别名字典流水
404
-func (c *Client) BatchSaveTableFieldAliasFlow(ctx context.Context, req *BatchTableFieldAliasRequest) ([]DicTableFieldAliasFlowDB, error) {
405
-	endpoint := "/api/dic-table-field-alias-flow/batch-save"
406
-
407
-	var result ResponseWrapper[[]DicTableFieldAliasFlowDB]
408
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
409
-		return nil, err
410
-	}
411
-
412
-	if !result.Success {
413
-		return nil, NewClientError("batch_save_table_field_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
414
-	}
415
-
416
-	return result.Data, nil
417
-}
418
-
419
-// BatchApprovalTableFieldAliasFlow 批量审批字段别名字典流水
420
-func (c *Client) BatchApprovalTableFieldAliasFlow(ctx context.Context, req *BatchApprovalFlowRequest) error {
421
-	endpoint := "/api/dic-table-field-alias-flow/batch-approval"
422
-
423
-	var result ResponseWrapper[int64]
424
-	if err := c.doRequest(ctx, http.MethodPost, endpoint, req, &result); err != nil {
425
-		return err
426
-	}
427
-
428
-	if !result.Success {
429
-		return NewClientError("batch_approval_table_field_alias_flow", fmt.Sprintf("API error: %s", result.Error), nil)
430
-	}
431
-
432
-	return nil
433
-}
434
-
435 277
 // doRequest 执行HTTP请求
436 278
 func (c *Client) doRequest(ctx context.Context, method, endpoint string, body interface{}, result interface{}) error {
437 279
 	// 构建URL

+ 76
- 69
sdk/configure/test/example.go Прегледај датотеку

@@ -30,8 +30,9 @@ func ExampleUsage() {
30 30
 	// 示例5:删除表
31 31
 	exampleDeleteTable()
32 32
 
33
-	// 示例6:别名字典管理
34
-	exampleAliasManagement()
33
+	// 示例6:批量保存表
34
+	exampleBatchSaveTables()
35
+
35 36
 }
36 37
 
37 38
 func exampleCreateClient() {
@@ -211,86 +212,92 @@ func exampleDeleteTable() {
211 212
 	fmt.Println()
212 213
 }
213 214
 
214
-func exampleAliasManagement() {
215
-	fmt.Println("=== 示例6:别名字典管理 ===")
215
+func exampleBatchSaveTables() {
216
+	fmt.Println("=== 示例6:批量保存数据库表字典 ===")
216 217
 
217
-	// 创建客户端
218
-	client, err := configure.NewBasicAuthClient("http://localhost:8080", "admin", "123")
218
+	// 创建客户端(使用Token认证)
219
+	// 注意:实际使用时需要从认证服务获取有效的token
220
+	client, err := configure.NewTokenAuthClient("http://localhost:8080", "your-valid-token-here")
219 221
 	if err != nil {
220 222
 		log.Printf("Failed to create client: %v", err)
221 223
 		return
222 224
 	}
223 225
 
224
-	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
225
-	defer cancel()
226
-
227
-	// 1. 创建表别名字典
228
-	tableAliasReq := &configure.TableAliasRequest{
229
-		TableID:    "example_table_001",
230
-		TableAlias: "示例表别名",
231
-	}
232
-
233
-	tableAliasDetail, err := client.SaveTableAlias(ctx, tableAliasReq)
234
-	if err != nil {
235
-		log.Printf("Error saving table alias: %v", err)
236
-		return
237
-	}
238
-	fmt.Printf("Table alias saved: ID=%s, TableID=%s, Alias=%s\n",
239
-		tableAliasDetail.TableAlias.ID,
240
-		tableAliasDetail.TableAlias.TableID,
241
-		tableAliasDetail.TableAlias.TableAlias)
242
-
243
-	// 2. 查询表别名字典列表
244
-	query := &configure.TableAliasQueryRequest{
245
-		QueryRequest: queryreq.QueryRequest{
246
-			Page:     0,
247
-			PageSize: 10,
226
+	// 创建批量保存请求
227
+	req := &configure.BatchSaveDicTablesRequest{
228
+		Tables: []configure.DicTableRequest{
229
+			{
230
+				TableID:     "batch_table_001",
231
+				TableType:   "实体表",
232
+				Name:        "批量测试表001",
233
+				Description: "批量测试表001描述",
234
+			},
235
+			{
236
+				TableID:     "batch_table_002",
237
+				TableType:   "视图",
238
+				Name:        "批量测试表002",
239
+				Description: "批量测试表002描述",
240
+			},
241
+		},
242
+		Fields: []configure.DicTableFieldRequest{
243
+			// 表1的字段
244
+			{
245
+				FieldID:     "batch_table_001.id",
246
+				TableID:     "batch_table_001",
247
+				FiledType:   "实际字段",
248
+				DataType:    "数值型",
249
+				FieldName:   "id",
250
+				FieldNameCN: "主键ID",
251
+				Description: "表1主键字段",
252
+			},
253
+			{
254
+				FieldID:     "batch_table_001.name",
255
+				TableID:     "batch_table_001",
256
+				FiledType:   "实际字段",
257
+				DataType:    "字符型",
258
+				FieldName:   "name",
259
+				FieldNameCN: "名称",
260
+				Description: "表1名称字段",
261
+			},
262
+			// 表2的字段
263
+			{
264
+				FieldID:     "batch_table_002.code",
265
+				TableID:     "batch_table_002",
266
+				FiledType:   "实际字段",
267
+				DataType:    "字符型",
268
+				FieldName:   "code",
269
+				FieldNameCN: "编码",
270
+				Description: "表2编码字段",
271
+			},
272
+			{
273
+				FieldID:     "batch_table_002.value",
274
+				TableID:     "batch_table_002",
275
+				FiledType:   "计算字段",
276
+				DataType:    "数值型",
277
+				FieldName:   "value",
278
+				FieldNameCN: "数值",
279
+				Description: "表2数值字段",
280
+			},
248 281
 		},
249
-		TableID: "example_table_001",
250
-	}
251
-
252
-	tableAliasList, err := client.ListTableAliases(ctx, query)
253
-	if err != nil {
254
-		log.Printf("Error listing table aliases: %v", err)
255
-		return
256
-	}
257
-	fmt.Printf("Total table aliases: %d\n", tableAliasList.TotalCount)
258
-
259
-	// 3. 创建字段别名字典
260
-	fieldAliasReq := &configure.TableFieldAliasRequest{
261
-		FieldID:        "example_table_001.id",
262
-		TableID:        "example_table_001",
263
-		FieldName:      "id",
264
-		FieldAlias:     "主键别名",
265
-		Description:    "主键字段别名",
266
-		WhereCondition: "查询条件描述",
267 282
 	}
268 283
 
269
-	fieldAliasDetail, err := client.SaveTableFieldAlias(ctx, fieldAliasReq)
270
-	if err != nil {
271
-		log.Printf("Error saving field alias: %v", err)
272
-		return
273
-	}
274
-	fmt.Printf("Field alias saved: ID=%s, FieldID=%s, Alias=%s\n",
275
-		fieldAliasDetail.TableFieldAlias.ID,
276
-		fieldAliasDetail.TableFieldAlias.FieldID,
277
-		fieldAliasDetail.TableFieldAlias.FieldAlias)
284
+	// 执行批量保存
285
+	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
286
+	defer cancel()
278 287
 
279
-	// 4. 查询字段别名字典列表
280
-	fieldQuery := &configure.TableFieldAliasQueryRequest{
281
-		QueryRequest: queryreq.QueryRequest{
282
-			Page:     0,
283
-			PageSize: 10,
284
-		},
285
-		TableID: "example_table_001",
286
-	}
288
+	fmt.Println("开始批量保存2个表,4个字段...")
289
+	startTime := time.Now()
287 290
 
288
-	fieldAliasList, err := client.ListTableFieldAliases(ctx, fieldQuery)
289
-	if err != nil {
290
-		log.Printf("Error listing field aliases: %v", err)
291
+	if err := client.BatchSaveTables(ctx, req); err != nil {
292
+		log.Printf("批量保存失败: %v", err)
291 293
 		return
292 294
 	}
293
-	fmt.Printf("Total field aliases: %d\n", fieldAliasList.TotalCount)
294 295
 
296
+	elapsed := time.Since(startTime)
297
+	fmt.Printf("批量保存成功!耗时: %v\n", elapsed)
298
+	fmt.Println("注意:示例中的token需要替换为实际有效的token")
299
+	fmt.Println("批量保存逻辑包括:")
300
+	fmt.Println("  1. 字段字典:先删除表的所有字段,再批量插入")
301
+	fmt.Println("  2. 表字典:存在则UPDATE,不存在则INSERT")
295 302
 	fmt.Println()
296 303
 }

+ 102
- 161
sdk/configure/types.go Прегледај датотеку

@@ -54,7 +54,6 @@ type DicTableQueryRequest struct {
54 54
 
55 55
 // DicTableDB 数据库表字典数据库模型
56 56
 type DicTableDB struct {
57
-	ID          string     `db:"id" json:"id"`
58 57
 	TableID     string     `db:"table_id" json:"tableID"`
59 58
 	TableType   string     `db:"table_type" json:"tableType"`
60 59
 	Name        string     `db:"table_name" json:"name"`
@@ -81,184 +80,126 @@ type DicTableFieldDB struct {
81 80
 	DeletedAt   *time.Time `db:"deleted_at" json:"deletedAt"`
82 81
 }
83 82
 
84
-// 数据库别名字典类型
85
-// 表别名字典数据库模型
86
-type DicTableAliasDB struct {
87
-	ID         string     `db:"id" json:"id"`
88
-	TableID    string     `db:"table_id" json:"tableID"`
89
-	TableAlias string     `db:"table_alias" json:"tableAlias"`
90
-	CreatedAt  time.Time  `db:"created_at" json:"createdAt"`
91
-	UpdatedAt  time.Time  `db:"updated_at" json:"updatedAt"`
92
-	DeletedAt  *time.Time `db:"deleted_at" json:"deletedAt"`
93
-}
94
-
95
-// 字段别名字典数据库模型
96
-type DicTableFieldAliasDB struct {
97
-	ID             string     `db:"id" json:"id"`
98
-	FieldID        string     `db:"field_id" json:"fieldID"`
99
-	TableID        string     `db:"table_id" json:"tableID"`
100
-	FieldName      string     `db:"field_name" json:"fieldName"`
101
-	FieldAlias     string     `db:"field_alias" json:"fieldAlias"`
102
-	Description    string     `db:"description" json:"description"`
103
-	WhereCondition string     `db:"where_condition" json:"whereCondition"`
104
-	CreatedAt      time.Time  `db:"created_at" json:"createdAt"`
105
-	UpdatedAt      time.Time  `db:"updated_at" json:"updatedAt"`
106
-	DeletedAt      *time.Time `db:"deleted_at" json:"deletedAt"`
107
-}
108
-
109
-// 表别名字典流水数据库模型
110
-type DicTableAliasFlowDB struct {
111
-	ID             string     `db:"id" json:"id"`
112
-	TableID        string     `db:"table_id" json:"tableID"`
113
-	TableAlias     string     `db:"table_alias" json:"tableAlias"`
114
-	TenantID       string     `db:"tenant_id" json:"tenantID"`
115
-	ApprovalStatus int8       `db:"approval_status" json:"approvalStatus"`
116
-	Approver       string     `db:"approver" json:"approver"`
117
-	ApprovedAt     *time.Time `db:"approved_at" json:"approvedAt"`
118
-	CreatedAt      time.Time  `db:"created_at" json:"createdAt"`
119
-	UpdatedAt      time.Time  `db:"updated_at" json:"updatedAt"`
120
-	DeletedAt      *time.Time `db:"deleted_at" json:"deletedAt"`
121
-}
122
-
123
-// 字段别名字典流水数据库模型
124
-type DicTableFieldAliasFlowDB struct {
125
-	ID             string     `db:"id" json:"id"`
126
-	FieldID        string     `db:"field_id" json:"fieldID"`
127
-	TableID        string     `db:"table_id" json:"tableID"`
128
-	FieldName      string     `db:"field_name" json:"fieldName"`
129
-	FieldAlias     string     `db:"field_alias" json:"fieldAlias"`
130
-	Description    string     `db:"description" json:"description"`
131
-	WhereCondition string     `db:"where_condition" json:"whereCondition"`
132
-	TenantID       string     `db:"tenant_id" json:"tenantID"`
133
-	ApprovalStatus int8       `db:"approval_status" json:"approvalStatus"`
134
-	Approver       string     `db:"approver" json:"approver"`
135
-	ApprovedAt     *time.Time `db:"approved_at" json:"approvedAt"`
136
-	CreatedAt      time.Time  `db:"created_at" json:"createdAt"`
137
-	UpdatedAt      time.Time  `db:"updated_at" json:"updatedAt"`
138
-	DeletedAt      *time.Time `db:"deleted_at" json:"deletedAt"`
139
-}
140
-
141
-// 表别名字典查询请求
142
-type TableAliasQueryRequest struct {
143
-	queryreq.QueryRequest // 通用查询请求(分页、排序、筛选)
144
-
145
-	// 向后兼容的旧字段(新客户端应使用QueryRequest中的Filters)
146
-	TableID    string `json:"tableID,omitempty"`    // 表ID模糊搜索
147
-	TableAlias string `json:"tableAlias,omitempty"` // 别名模糊搜索
148
-	SortField  string `json:"sortField,omitempty"`  // 排序字段(单字段)
149
-	SortOrder  string `json:"sortOrder,omitempty"`  // 排序方向: asc/desc
83
+// BatchSaveDicTablesRequest 批量保存数据库表字典请求
84
+type BatchSaveDicTablesRequest struct {
85
+	Tables []DicTableRequest      `json:"tables" binding:"required"`
86
+	Fields []DicTableFieldRequest `json:"fields" binding:"required"`
150 87
 }
151 88
 
152
-// 表别名字典请求
89
+// TableAliasRequest 表别名字典请求
153 90
 type TableAliasRequest struct {
154
-	ID         string `json:"id,omitempty"`                  // 主键(创建时可选,更新时必填)
155
-	TableID    string `json:"tableID" binding:"required"`    // 表ID
156
-	TableAlias string `json:"tableAlias" binding:"required"` // 别名
157
-}
158
-
159
-// 批量表别名字典请求
160
-type BatchTableAliasRequest struct {
161
-	Items []TableAliasRequest `json:"items" binding:"required"` // 表别名列表
162
-}
163
-
164
-// 表别名字典详情
165
-type TableAliasDetail struct {
166
-	TableAlias DicTableAliasDB `json:"tableAlias"` // 表别名字典信息
167
-}
168
-
169
-// 表别名字典列表
170
-type TableAliasList struct {
171
-	TotalCount int               `json:"totalCount"`
172
-	LastPage   int               `json:"lastPage"`
173
-	Data       []DicTableAliasDB `json:"data"`
91
+	TableID    string `json:"tableID" binding:"required"`
92
+	TableAlias string `json:"tableAlias" binding:"required"`
174 93
 }
175 94
 
176
-// 字段别名字典查询请求
177
-type TableFieldAliasQueryRequest struct {
178
-	queryreq.QueryRequest // 通用查询请求(分页、排序、筛选)
179
-
180
-	// 向后兼容的旧字段(新客户端应使用QueryRequest中的Filters)
181
-	TableID    string `json:"tableID,omitempty"`    // 表ID模糊搜索
182
-	FieldID    string `json:"fieldID,omitempty"`    // 字段ID模糊搜索
183
-	FieldName  string `json:"fieldName,omitempty"`  // 字段名称模糊搜索
184
-	FieldAlias string `json:"fieldAlias,omitempty"` // 字段别名模糊搜索
185
-	SortField  string `json:"sortField,omitempty"`  // 排序字段(单字段)
186
-	SortOrder  string `json:"sortOrder,omitempty"`  // 排序方向: asc/desc
187
-}
188
-
189
-// 字段别名字典请求
95
+// TableFieldAliasRequest 表字段别名字典请求
190 96
 type TableFieldAliasRequest struct {
191
-	ID             string `json:"id,omitempty"`                  // 主键(创建时可选,更新时必填)
192
-	FieldID        string `json:"fieldID" binding:"required"`    // 字段ID
193
-	TableID        string `json:"tableID" binding:"required"`    // 表ID
194
-	FieldName      string `json:"fieldName" binding:"required"`  // 字段名称
195
-	FieldAlias     string `json:"fieldAlias" binding:"required"` // 字段别名
196
-	Description    string `json:"description"`                   // 字段别名描述
197
-	WhereCondition string `json:"whereCondition"`                // 此别名获取数据的查询条件描述
198
-}
199
-
200
-// 批量字段别名字典请求
201
-type BatchTableFieldAliasRequest struct {
202
-	Items []TableFieldAliasRequest `json:"items" binding:"required"` // 字段别名列表
97
+	FieldID    string `json:"fieldID" binding:"required"`
98
+	FieldAlias string `json:"fieldAlias" binding:"required"`
203 99
 }
204 100
 
205
-// 字段别名字典详情
206
-type TableFieldAliasDetail struct {
207
-	TableFieldAlias DicTableFieldAliasDB `json:"tableFieldAlias"` // 字段别名字典信息
101
+// BatchTableSyncRequest 批量表同步请求
102
+type BatchTableSyncRequest struct {
103
+	Tables []DicTableRequest      `json:"tables" binding:"required"`
104
+	Fields []DicTableFieldRequest `json:"fields" binding:"required"`
208 105
 }
209 106
 
210
-// 字段别名字典列表
211
-type TableFieldAliasList struct {
212
-	TotalCount int                    `json:"totalCount"`
213
-	LastPage   int                    `json:"lastPage"`
214
-	Data       []DicTableFieldAliasDB `json:"data"`
107
+// BatchAliasSyncRequest 批量别名同步请求
108
+type BatchAliasSyncRequest struct {
109
+	TableAliases []TableAliasRequest      `json:"tableAliases" binding:"required"`
110
+	FieldAliases []TableFieldAliasRequest `json:"fieldAliases" binding:"required"`
215 111
 }
216 112
 
217
-// 表别名字典流水查询请求
218
-type TableAliasFlowQueryRequest struct {
219
-	queryreq.QueryRequest // 通用查询请求(分页、排序、筛选)
220
-
221
-	// 向后兼容的旧字段
222
-	TableID        string `json:"tableID,omitempty"`        // 表ID模糊搜索
223
-	TableAlias     string `json:"tableAlias,omitempty"`     // 别名模糊搜索
224
-	TenantID       string `json:"tenantID,omitempty"`       // 租户ID精确搜索
225
-	ApprovalStatus int8   `json:"approvalStatus,omitempty"` // 审批状态精确搜索
226
-	SortField      string `json:"sortField,omitempty"`      // 排序字段(单字段)
227
-	SortOrder      string `json:"sortOrder,omitempty"`      // 排序方向: asc/desc
113
+// TableAliasQueryRequest 表别名字典查询请求
114
+type TableAliasQueryRequest struct {
115
+	TableID    string `json:"tableID,omitempty"`
116
+	TableAlias string `json:"tableAlias,omitempty"`
228 117
 }
229 118
 
230
-// 字段别名字典流水查询请求
231
-type TableFieldAliasFlowQueryRequest struct {
232
-	queryreq.QueryRequest // 通用查询请求(分页、排序、筛选)
233
-
234
-	// 向后兼容的旧字段
235
-	TableID        string `json:"tableID,omitempty"`        // 表ID模糊搜索
236
-	FieldID        string `json:"fieldID,omitempty"`        // 字段ID模糊搜索
237
-	FieldName      string `json:"fieldName,omitempty"`      // 字段名称模糊搜索
238
-	FieldAlias     string `json:"fieldAlias,omitempty"`     // 字段别名模糊搜索
239
-	TenantID       string `json:"tenantID,omitempty"`       // 租户ID精确搜索
240
-	ApprovalStatus int8   `json:"approvalStatus,omitempty"` // 审批状态精确搜索
241
-	SortField      string `json:"sortField,omitempty"`      // 排序字段(单字段)
242
-	SortOrder      string `json:"sortOrder,omitempty"`      // 排序方向: asc/desc
119
+// TableFieldAliasQueryRequest 表字段别名字典查询请求
120
+type TableFieldAliasQueryRequest struct {
121
+	FieldID    string `json:"fieldID,omitempty"`
122
+	FieldAlias string `json:"fieldAlias,omitempty"`
123
+}
124
+
125
+// BatchTableSyncResponse 批量表同步响应
126
+type BatchTableSyncResponse struct {
127
+	TotalTables   int                        `json:"totalTables"`
128
+	CreatedTables int                        `json:"createdTables"`
129
+	UpdatedTables int                        `json:"updatedTables"`
130
+	DeletedTables int                        `json:"deletedTables"`
131
+	TotalFields   int                        `json:"totalFields"`
132
+	CreatedFields int                        `json:"createdFields"`
133
+	UpdatedFields int                        `json:"updatedFields"`
134
+	DeletedFields int                        `json:"deletedFields"`
135
+	FailedTables  []BatchTableSyncFailedItem `json:"failedTables"`
136
+	FailedFields  []BatchFieldSyncFailedItem `json:"failedFields"`
137
+}
138
+
139
+// BatchTableSyncFailedItem 批量表同步失败项
140
+type BatchTableSyncFailedItem struct {
141
+	TableID string `json:"tableID"`
142
+	Error   string `json:"error"`
143
+}
144
+
145
+// BatchFieldSyncFailedItem 批量字段同步失败项
146
+type BatchFieldSyncFailedItem struct {
147
+	FieldID string `json:"fieldID"`
148
+	Error   string `json:"error"`
149
+}
150
+
151
+// BatchAliasSyncResponse 批量别名同步响应
152
+type BatchAliasSyncResponse struct {
153
+	TotalTableAliases   int                        `json:"totalTableAliases"`
154
+	CreatedTableAliases int                        `json:"createdTableAliases"`
155
+	UpdatedTableAliases int                        `json:"updatedTableAliases"`
156
+	DeletedTableAliases int                        `json:"deletedTableAliases"`
157
+	TotalFieldAliases   int                        `json:"totalFieldAliases"`
158
+	CreatedFieldAliases int                        `json:"createdFieldAliases"`
159
+	UpdatedFieldAliases int                        `json:"updatedFieldAliases"`
160
+	DeletedFieldAliases int                        `json:"deletedFieldAliases"`
161
+	FailedTableAliases  []BatchAliasSyncFailedItem `json:"failedTableAliases"`
162
+	FailedFieldAliases  []BatchAliasSyncFailedItem `json:"failedFieldAliases"`
163
+}
164
+
165
+// BatchAliasSyncFailedItem 批量别名同步失败项
166
+type BatchAliasSyncFailedItem struct {
167
+	AliasID string `json:"aliasID"`
168
+	Error   string `json:"error"`
169
+}
170
+
171
+// TableAliasResponse 表别名字典响应
172
+type TableAliasResponse struct {
173
+	ID         string     `db:"id" json:"id"`
174
+	TableID    string     `db:"table_id" json:"tableID"`
175
+	TableAlias string     `db:"table_alias" json:"tableAlias"`
176
+	Creator    string     `db:"creator" json:"creator"`
177
+	CreatedAt  time.Time  `db:"created_at" json:"createdAt"`
178
+	UpdatedAt  time.Time  `db:"updated_at" json:"updatedAt"`
179
+	DeletedAt  *time.Time `db:"deleted_at" json:"deletedAt"`
243 180
 }
244 181
 
245
-// 批量审批流水请求
246
-type BatchApprovalFlowRequest struct {
247
-	IDs            []string `json:"ids" binding:"required"`            // 流水记录ID列表
248
-	ApprovalStatus int8     `json:"approvalStatus" binding:"required"` // 审批状态:0待审批,1通过,2拒绝
249
-	Approver       string   `json:"approver" binding:"required"`       // 审批人
182
+// TableFieldAliasResponse 表字段别名字典响应
183
+type TableFieldAliasResponse struct {
184
+	ID         string     `db:"id" json:"id"`
185
+	FieldID    string     `db:"field_id" json:"fieldID"`
186
+	FieldAlias string     `db:"field_alias" json:"fieldAlias"`
187
+	Creator    string     `db:"creator" json:"creator"`
188
+	CreatedAt  time.Time  `db:"created_at" json:"createdAt"`
189
+	UpdatedAt  time.Time  `db:"updated_at" json:"updatedAt"`
190
+	DeletedAt  *time.Time `db:"deleted_at" json:"deletedAt"`
250 191
 }
251 192
 
252
-// 表别名字典流水列表
253
-type TableAliasFlowList struct {
254
-	TotalCount int                   `json:"totalCount"`
255
-	LastPage   int                   `json:"lastPage"`
256
-	Data       []DicTableAliasFlowDB `json:"data"`
193
+// TableAliasList 表别名字典列表
194
+type TableAliasList struct {
195
+	TotalCount int                  `json:"totalCount"`
196
+	LastPage   int                  `json:"lastPage"`
197
+	Data       []TableAliasResponse `json:"data"`
257 198
 }
258 199
 
259
-// 字段别名字典流水列表
260
-type TableFieldAliasFlowList struct {
261
-	TotalCount int                        `json:"totalCount"`
262
-	LastPage   int                        `json:"lastPage"`
263
-	Data       []DicTableFieldAliasFlowDB `json:"data"`
200
+// TableFieldAliasList 表字段别名字典列表
201
+type TableFieldAliasList struct {
202
+	TotalCount int                       `json:"totalCount"`
203
+	LastPage   int                       `json:"lastPage"`
204
+	Data       []TableFieldAliasResponse `json:"data"`
264 205
 }

Loading…
Откажи
Сачувај