mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-17 11:12:34 +08:00
系统架构层面流量控制功能完善
This commit is contained in:
25
dispatch/dao/client_log_mongo.go
Normal file
25
dispatch/dao/client_log_mongo.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hk4e/dispatch/model"
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func (d *Dao) InsertClientLog(clientLog *model.ClientLog) (primitive.ObjectID, error) {
|
||||
db := d.db.Collection("client_log")
|
||||
id, err := db.InsertOne(context.TODO(), clientLog)
|
||||
if err != nil {
|
||||
return primitive.ObjectID{}, err
|
||||
} else {
|
||||
_id, ok := id.InsertedID.(primitive.ObjectID)
|
||||
if !ok {
|
||||
logger.Error("get insert id error")
|
||||
return primitive.ObjectID{}, nil
|
||||
}
|
||||
return _id, nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user