refactor: 部分日志请求入参调整为json

This commit is contained in:
meilin.huang
2023-09-09 23:34:26 +08:00
parent 08c381fa60
commit 8e75e1f6ef
16 changed files with 98 additions and 88 deletions

View File

@@ -93,11 +93,7 @@ func (m *Mongo) RunCommand(rc *req.Ctx) {
ginx.BindJsonAndValid(rc.GinCtx, commandForm)
inst := m.MongoApp.GetMongoInst(m.GetMongoId(rc.GinCtx))
rc.ReqParam = jsonx.ToStr(map[string]any{
"info": inst.Info.GetLogDesc(),
"req": commandForm,
})
rc.ReqParam = jsonx.Kvs("mongo", inst.Info, "cmd", commandForm)
// 顺序执行
commands := bson.D{}
@@ -160,10 +156,7 @@ func (m *Mongo) UpdateByIdCommand(rc *req.Ctx) {
ginx.BindJsonAndValid(g, commandForm)
inst := m.MongoApp.GetMongoInst(m.GetMongoId(g))
rc.ReqParam = jsonx.ToStr(map[string]any{
"info": inst.Info.GetLogDesc(),
"req": commandForm,
})
rc.ReqParam = jsonx.Kvs("mongo", inst.Info, "cmd", commandForm)
// 解析docId文档id如果为string类型则使用ObjectId解析解析失败则为普通字符串
docId := commandForm.DocId
@@ -187,10 +180,7 @@ func (m *Mongo) DeleteByIdCommand(rc *req.Ctx) {
ginx.BindJsonAndValid(g, commandForm)
inst := m.MongoApp.GetMongoInst(m.GetMongoId(g))
rc.ReqParam = jsonx.ToStr(map[string]any{
"info": inst.Info.GetLogDesc(),
"req": commandForm,
})
rc.ReqParam = jsonx.Kvs("mongo", inst.Info, "cmd", commandForm)
// 解析docId文档id如果为string类型则使用ObjectId解析解析失败则为普通字符串
docId := commandForm.DocId
@@ -213,10 +203,7 @@ func (m *Mongo) InsertOneCommand(rc *req.Ctx) {
ginx.BindJsonAndValid(g, commandForm)
inst := m.MongoApp.GetMongoInst(m.GetMongoId(g))
rc.ReqParam = jsonx.ToStr(map[string]any{
"info": inst.Info.GetLogDesc(),
"req": commandForm,
})
rc.ReqParam = jsonx.Kvs("mongo", inst.Info, "cmd", commandForm)
res, err := inst.Cli.Database(commandForm.Database).Collection(commandForm.Collection).InsertOne(context.TODO(), commandForm.Doc)
biz.ErrIsNilAppendErr(err, "命令执行失败: %s")

View File

@@ -142,10 +142,10 @@ func DeleteMongoCache(mongoId uint64) {
}
type MongoInfo struct {
Id uint64
Name string
TagPath string
SshTunnelMachineId int // ssh隧道机器id
Id uint64 `json:"id"`
Name string `json:"name"`
TagPath string `json:"tagPath"`
SshTunnelMachineId int `json:"-"` // ssh隧道机器id
}
func (m *MongoInfo) GetLogDesc() string {