|
|
@@ -15,9 +15,10 @@ import (
|
|
|
)
|
|
|
|
|
|
type Client struct {
|
|
|
- conn *grpc.ClientConn
|
|
|
- commandServiceClient v1.CommandServiceClient
|
|
|
- queryServiceClient v1.QueryServiceClient
|
|
|
+ conn *grpc.ClientConn
|
|
|
+ commandServiceClient v1.CommandServiceClient
|
|
|
+ queryServiceClient v1.QueryServiceClient
|
|
|
+ eventQueryServiceClient v1.EventQueryServiceClient
|
|
|
}
|
|
|
|
|
|
func NewClient(address string) (*Client, error) {
|
|
|
@@ -28,9 +29,10 @@ func NewClient(address string) (*Client, error) {
|
|
|
}
|
|
|
|
|
|
return &Client{
|
|
|
- conn: conn,
|
|
|
- commandServiceClient: v1.NewCommandServiceClient(conn),
|
|
|
- queryServiceClient: v1.NewQueryServiceClient(conn),
|
|
|
+ conn: conn,
|
|
|
+ commandServiceClient: v1.NewCommandServiceClient(conn),
|
|
|
+ queryServiceClient: v1.NewQueryServiceClient(conn),
|
|
|
+ eventQueryServiceClient: v1.NewEventQueryServiceClient(conn),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
@@ -273,8 +275,8 @@ func (c *Client) QueryByWhereAndOrderBy(req *ports.QueryByWhereAndOrderByRequest
|
|
|
Select: req.Select,
|
|
|
Where: whereJsonBytes,
|
|
|
OrderBy: req.OrderBy,
|
|
|
- PageNo: req.PageNo,
|
|
|
- PageSize: req.PageSize,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return "", nil, 0, err
|
|
|
@@ -315,8 +317,8 @@ func (c *Client) CommonQuery(req *ports.CommonQueryRequest) (string, []map[strin
|
|
|
GroupBy: req.GroupBy,
|
|
|
Join: req.Join,
|
|
|
Having: havingJsonBytes,
|
|
|
- PageNo: req.PageNo,
|
|
|
- PageSize: req.PageSize,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return "", nil, 0, err
|
|
|
@@ -402,6 +404,142 @@ func (c *Client) CommonCount(req *ports.CommonCountRequest) (string, int64, erro
|
|
|
return reply.Statement, reply.Count, nil
|
|
|
}
|
|
|
|
|
|
+func (c *Client) EventQueryByKeys(req *ports.EventQueryByKeysRequest) (string, []ports.EventInfo, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.EventQueryByKeys(context.Background(), &request.EventQueryByKeysRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ Select: req.Select,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, ports.FormEventInfoBatch(reply.Infos), reply.TotalCount, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CommonEventQuery(req *ports.CommonEventQueryRequest) (string, []ports.EventInfo, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CommonEventQuery(context.Background(), &request.CommonEventQueryRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ Select: req.Select,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ Version: req.Version,
|
|
|
+ Operation: req.Operation,
|
|
|
+ CreatorID: req.CreatorID,
|
|
|
+ StartCreatedTime: req.StartCreatedTime,
|
|
|
+ EndCreatedTime: req.EndCreatedTime,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, ports.FormEventInfoBatch(reply.Infos), reply.TotalCount, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CountEventByKeys(req *ports.CountEventByKeysRequest) (string, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CountEventByKeys(context.Background(), &request.CountEventByKeysRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, reply.Count, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CommonCountEvent(req *ports.CommonCountEventRequest) (string, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CommonCountEvent(context.Background(), &request.CommonCountEventRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ Version: req.Version,
|
|
|
+ Operation: req.Operation,
|
|
|
+ CreatorID: req.CreatorID,
|
|
|
+ StartCreatedTime: req.StartCreatedTime,
|
|
|
+ EndCreatedTime: req.EndCreatedTime,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, reply.Count, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) EventHistoryQueryByKeys(req *ports.EventQueryByKeysRequest) (string, []ports.EventInfo, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.EventHistoryQueryByKeys(context.Background(), &request.EventQueryByKeysRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ Select: req.Select,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, ports.FormEventInfoBatch(reply.Infos), reply.TotalCount, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CommonEventHistoryQuery(req *ports.CommonEventQueryRequest) (string, []ports.EventInfo, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CommonEventHistoryQuery(context.Background(), &request.CommonEventQueryRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ Select: req.Select,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ Version: req.Version,
|
|
|
+ Operation: req.Operation,
|
|
|
+ CreatorID: req.CreatorID,
|
|
|
+ StartCreatedTime: req.StartCreatedTime,
|
|
|
+ EndCreatedTime: req.EndCreatedTime,
|
|
|
+ PageNo: int32(req.PageNo),
|
|
|
+ PageSize: int32(req.PageSize),
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, ports.FormEventInfoBatch(reply.Infos), reply.TotalCount, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CountEventHistoryByKeys(req *ports.CountEventByKeysRequest) (string, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CountEventHistoryByKeys(context.Background(), &request.CountEventByKeysRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, reply.Count, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CommonCountEventHistory(req *ports.CommonCountEventRequest) (string, int64, error) {
|
|
|
+ reply, err := c.eventQueryServiceClient.CommonCountEventHistory(context.Background(), &request.CommonCountEventRequest{
|
|
|
+ DatabaseID: req.DatabaseID,
|
|
|
+ TablePrefixWithSchema: req.TablePrefixWithSchema,
|
|
|
+ KeyValues: req.KeyValues,
|
|
|
+ Version: req.Version,
|
|
|
+ Operation: req.Operation,
|
|
|
+ CreatorID: req.CreatorID,
|
|
|
+ StartCreatedTime: req.StartCreatedTime,
|
|
|
+ EndCreatedTime: req.EndCreatedTime,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return "", 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return reply.Statement, reply.Count, nil
|
|
|
+}
|
|
|
+
|
|
|
func (c *Client) formTableRow(tableRow map[string]any) (*request.TableRow, error) {
|
|
|
if tableRow == nil || len(tableRow) == 0 {
|
|
|
return &request.TableRow{Columns: make([]*request.Column, 0)}, nil
|