Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50c23df124 | ||
|
|
04b8e5b03b |
@@ -8,6 +8,7 @@ type Base struct {
|
||||
BindIP string `yaml:"BindIP"` // 绑定IP
|
||||
Addr string `yaml:"Addr"`
|
||||
OnMicroService bool `yaml:"OnMicroService"`
|
||||
LoginUrl string `yaml:"LoginUrl"`
|
||||
}
|
||||
|
||||
type DBConf struct {
|
||||
|
||||
32
oplog/new.go
Normal file
32
oplog/new.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package oplog
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(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
|
||||
}
|
||||
18
oplog/types.go
Normal file
18
oplog/types.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package oplog
|
||||
|
||||
type LogItem struct {
|
||||
OpID uint `json:"op_id"`
|
||||
OpName string `json:"op_name"`
|
||||
OpType string `json:"op_type"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
var (
|
||||
Type_Login string = "login"
|
||||
Type_Logout string = "logout"
|
||||
Type_Register string = "register"
|
||||
Type_Update string = "update"
|
||||
Type_Delete string = "delete"
|
||||
Type_Query string = "query"
|
||||
Type_Other string = "other"
|
||||
)
|
||||
Reference in New Issue
Block a user