Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2de73fea00 | ||
|
|
4b73f086b1 | ||
|
|
c08950c10a |
28
oplog/new.go
28
oplog/new.go
@@ -1,32 +1,14 @@
|
|||||||
package oplog
|
package oplog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
|
||||||
|
"git.apinb.com/bsm-sdk/core/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(endpoint string, data LogRequest) error {
|
func New(endpoint string, data []*LogItem) {
|
||||||
go PostLog(data, endpoint)
|
jsonBytes, _ := json.Marshal(data)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func PostLog(data LogRequest, endpoint string) (resp *http.Response, err error) {
|
|
||||||
jsonBytes, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(jsonBytes))
|
go utils.HttpPost(endpoint, nil, jsonBytes)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package oplog
|
package oplog
|
||||||
|
|
||||||
type LogRequest struct {
|
|
||||||
Data []*LogItem `json:"data"`
|
|
||||||
}
|
|
||||||
type LogItem struct {
|
type LogItem struct {
|
||||||
OpID uint `json:"op_id"`
|
OpID uint `json:"op_id"`
|
||||||
OpName string `json:"op_name"`
|
OpName string `json:"op_name"`
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ type (
|
|||||||
// standard ID,Identity definition.
|
// standard ID,Identity definition.
|
||||||
Std_IDIdentity struct {
|
Std_IDIdentity struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"primarykey;" json:"id"`
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;default:uuid_generate_v4()" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Created,Updated,Deleted definition.
|
// standard ID,Created,Updated,Deleted definition.
|
||||||
Std_IICUDS struct {
|
Std_IICUDS struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"primarykey;" json:"id"`
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;default:uuid_generate_v4()" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
||||||
@@ -51,7 +51,7 @@ type (
|
|||||||
// standard PassportID,PassportIdentity definition.
|
// standard PassportID,PassportIdentity definition.
|
||||||
Std_Passport struct {
|
Std_Passport struct {
|
||||||
PassportID uint `gorm:"column:passport_id;Index;" json:"passport_id"`
|
PassportID uint `gorm:"column:passport_id;Index;" json:"passport_id"`
|
||||||
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;default:uuid_generate_v4()" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为ULID
|
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为ULID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID definition.
|
// standard ID definition.
|
||||||
@@ -61,7 +61,7 @@ type (
|
|||||||
|
|
||||||
// standard Identity definition.
|
// standard Identity definition.
|
||||||
Std_Identity struct {
|
Std_Identity struct {
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;default:uuid_generate_v4()" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard Status definition.
|
// standard Status definition.
|
||||||
|
|||||||
Reference in New Issue
Block a user