refactor: 将 OpType 字段从枚举类型改为 string 类型
主要变更: - Operation.OpType: Type → string - NewFullOperation 参数: opType Type → opType string - IsValidOpType 参数: opType Type → opType string - operationMeta.OpType: *Type → *string - queryclient.ListRequest.OpType: model.Type → string 优点: - 更灵活,支持动态扩展操作类型 - 不再受限于预定义的枚举常量 - 简化类型转换逻辑 兼容性: - Type 常量定义保持不变 (OpTypeCreate, OpTypeUpdate 等) - 使用时需要 string() 转换: string(model.OpTypeCreate) - 所有单元测试已更新并通过 (100%) 测试结果: ✅ api/adapter - PASS ✅ api/highclient - PASS ✅ api/logger - PASS ✅ api/model - PASS ✅ api/persistence - PASS ✅ api/queryclient - PASS ✅ internal/* - PASS
This commit is contained in:
@@ -76,7 +76,7 @@ type ListOperationsRequest struct {
|
||||
// 可选过滤条件
|
||||
Timestamp *time.Time // 操作时间戳
|
||||
OpSource model.Source // 操作来源
|
||||
OpType model.Type // 操作类型
|
||||
OpType string // 操作类型
|
||||
DoPrefix string // 数据前缀
|
||||
DoRepository string // 数据仓库
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (c *Client) ListOperations(ctx context.Context, req ListOperationsRequest)
|
||||
pbReq := &pb.ListOperationReq{
|
||||
PageSize: req.PageSize,
|
||||
OpSource: string(req.OpSource),
|
||||
OpType: string(req.OpType),
|
||||
OpType: req.OpType,
|
||||
DoPrefix: req.DoPrefix,
|
||||
DoRepository: req.DoRepository,
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestListOperations_ErrorHandling(t *testing.T) {
|
||||
|
||||
assert.Equal(t, uint64(10), req.PageSize)
|
||||
assert.Equal(t, model.Source("api"), req.OpSource)
|
||||
assert.Equal(t, model.Type("create"), req.OpType)
|
||||
assert.Equal(t, "create", req.OpType)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ func TestListOperationsRequest(t *testing.T) {
|
||||
PreTime: now,
|
||||
Timestamp: &now,
|
||||
OpSource: model.Source("test"),
|
||||
OpType: model.Type("create"),
|
||||
OpType: "create",
|
||||
}
|
||||
|
||||
assert.Equal(t, uint64(10), req.PageSize)
|
||||
|
||||
Reference in New Issue
Block a user