From 4b73f086b153cb73a60de1dfbf1b4a6b4479150f Mon Sep 17 00:00:00 2001 From: zhaoxiaorong Date: Fri, 11 Apr 2025 18:14:07 +0800 Subject: [PATCH] dev oplog --- oplog/new.go | 28 +++++----------------------- oplog/types.go | 3 --- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/oplog/new.go b/oplog/new.go index c0e5e72..b050d63 100644 --- a/oplog/new.go +++ b/oplog/new.go @@ -1,32 +1,14 @@ package oplog import ( - "bytes" "encoding/json" - "net/http" + + "git.apinb.com/bsm-sdk/core/utils" ) -func New(endpoint string, data []*LogItem) error { - go PostLog(data, endpoint) - return nil -} -func PostLog(data []*LogItem, endpoint string) (resp *http.Response, err error) { - jsonBytes, err := json.Marshal(data) - if err != nil { - return nil, err - } +func New(endpoint string, data []*LogItem) { + jsonBytes, _ := json.Marshal(data) - req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(jsonBytes)) - if err != nil { - return nil, err - } + go utils.HttpPost(endpoint, nil, jsonBytes) - req.Header.Set("Content-Type", "application/json") - client := &http.Client{} - resp, err = client.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - return } diff --git a/oplog/types.go b/oplog/types.go index dd93a77..1851c58 100644 --- a/oplog/types.go +++ b/oplog/types.go @@ -1,8 +1,5 @@ package oplog -type LogRequest struct { - Data []*LogItem `json:"data"` -} type LogItem struct { OpID uint `json:"op_id"` OpName string `json:"op_name"`