mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-26 01:16:36 +08:00
refactor: 包名变更ctx -> req
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"mayfly-go/internal/mongo/api"
|
||||
"mayfly-go/internal/mongo/application"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -19,68 +19,68 @@ func InitMongoRouter(router *gin.RouterGroup) {
|
||||
|
||||
// 获取所有mongo列表
|
||||
m.GET("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(ma.Mongos)
|
||||
})
|
||||
|
||||
saveMongo := ctx.NewLogInfo("mongo-保存信息")
|
||||
saveMongo := req.NewLogInfo("mongo-保存信息")
|
||||
m.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(saveMongo).
|
||||
Handle(ma.Save)
|
||||
})
|
||||
|
||||
deleteMongo := ctx.NewLogInfo("mongo-删除信息")
|
||||
deleteMongo := req.NewLogInfo("mongo-删除信息")
|
||||
m.DELETE(":id", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(deleteMongo).
|
||||
Handle(ma.DeleteMongo)
|
||||
})
|
||||
|
||||
// 获取mongo下的所有数据库
|
||||
m.GET(":id/databases", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(ma.Databases)
|
||||
})
|
||||
|
||||
// 获取mongo指定库的所有集合
|
||||
m.GET(":id/collections", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(ma.Collections)
|
||||
})
|
||||
|
||||
// 获取mongo runCommand
|
||||
m.POST(":id/run-command", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(ma.RunCommand)
|
||||
})
|
||||
|
||||
// 执行mongo find命令
|
||||
m.POST(":id/command/find", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(ma.FindCommand)
|
||||
})
|
||||
|
||||
// 执行mongo update by id命令
|
||||
updateDocById := ctx.NewLogInfo("mongo-更新文档").WithSave(true)
|
||||
updateDocById := req.NewLogInfo("mongo-更新文档").WithSave(true)
|
||||
m.POST(":id/command/update-by-id", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(updateDocById).
|
||||
Handle(ma.UpdateByIdCommand)
|
||||
})
|
||||
|
||||
// 执行mongo delete by id命令
|
||||
deleteDoc := ctx.NewLogInfo("mongo-删除文档").WithSave(true)
|
||||
deleteDoc := req.NewLogInfo("mongo-删除文档").WithSave(true)
|
||||
m.POST(":id/command/delete-by-id", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(deleteDoc).
|
||||
Handle(ma.DeleteByIdCommand)
|
||||
})
|
||||
|
||||
// 执行mongo insert 命令
|
||||
insertDoc := ctx.NewLogInfo("mongo-新增文档").WithSave(true)
|
||||
insertDoc := req.NewLogInfo("mongo-新增文档").WithSave(true)
|
||||
m.POST(":id/command/insert", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(insertDoc).
|
||||
Handle(ma.InsertOneCommand)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user