mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	refactor: 部分日志请求入参调整为json
This commit is contained in:
		@@ -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")
 | 
			
		||||
 
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user