mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	refactor: 包名变更ctx -> req
This commit is contained in:
		@@ -4,7 +4,7 @@ import (
 | 
			
		||||
	"mayfly-go/internal/machine/api"
 | 
			
		||||
	"mayfly-go/internal/machine/application"
 | 
			
		||||
	sysApplication "mayfly-go/internal/sys/application"
 | 
			
		||||
	"mayfly-go/pkg/ctx"
 | 
			
		||||
	"mayfly-go/pkg/req"
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
)
 | 
			
		||||
@@ -19,66 +19,66 @@ func InitMachineFileRouter(router *gin.RouterGroup) {
 | 
			
		||||
 | 
			
		||||
		// 获取指定机器文件列表
 | 
			
		||||
		machineFile.GET(":machineId/files", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).Handle(mf.MachineFiles)
 | 
			
		||||
			req.NewCtxWithGin(c).Handle(mf.MachineFiles)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		// 新增修改机器文件
 | 
			
		||||
		addFileConf := ctx.NewLogInfo("机器-新增文件配置").WithSave(true)
 | 
			
		||||
		afcP := ctx.NewPermission("machine:file:add")
 | 
			
		||||
		addFileConf := req.NewLogInfo("机器-新增文件配置").WithSave(true)
 | 
			
		||||
		afcP := req.NewPermission("machine:file:add")
 | 
			
		||||
		machineFile.POST(":machineId/files", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(addFileConf).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(addFileConf).
 | 
			
		||||
				WithRequiredPermission(afcP).
 | 
			
		||||
				Handle(mf.SaveMachineFiles)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		// 删除机器文件
 | 
			
		||||
		delFileConf := ctx.NewLogInfo("机器-删除文件配置").WithSave(true)
 | 
			
		||||
		dfcP := ctx.NewPermission("machine:file:del")
 | 
			
		||||
		delFileConf := req.NewLogInfo("机器-删除文件配置").WithSave(true)
 | 
			
		||||
		dfcP := req.NewPermission("machine:file:del")
 | 
			
		||||
		machineFile.DELETE(":machineId/files/:fileId", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(delFileConf).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(delFileConf).
 | 
			
		||||
				WithRequiredPermission(dfcP).
 | 
			
		||||
				Handle(mf.DeleteFile)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		getContent := ctx.NewLogInfo("机器-获取文件内容").WithSave(true)
 | 
			
		||||
		getContent := req.NewLogInfo("机器-获取文件内容").WithSave(true)
 | 
			
		||||
		machineFile.GET(":machineId/files/:fileId/read", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(getContent).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(getContent).
 | 
			
		||||
				Handle(mf.ReadFileContent)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		getDir := ctx.NewLogInfo("机器-获取目录")
 | 
			
		||||
		getDir := req.NewLogInfo("机器-获取目录")
 | 
			
		||||
		machineFile.GET(":machineId/files/:fileId/read-dir", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(getDir).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(getDir).
 | 
			
		||||
				Handle(mf.GetDirEntry)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		writeFile := ctx.NewLogInfo("机器-修改文件内容").WithSave(true)
 | 
			
		||||
		wfP := ctx.NewPermission("machine:file:write")
 | 
			
		||||
		writeFile := req.NewLogInfo("机器-修改文件内容").WithSave(true)
 | 
			
		||||
		wfP := req.NewPermission("machine:file:write")
 | 
			
		||||
		machineFile.POST(":machineId/files/:fileId/write", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(writeFile).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(writeFile).
 | 
			
		||||
				WithRequiredPermission(wfP).
 | 
			
		||||
				Handle(mf.WriteFileContent)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		createFile := ctx.NewLogInfo("机器-创建文件or目录").WithSave(true)
 | 
			
		||||
		createFile := req.NewLogInfo("机器-创建文件or目录").WithSave(true)
 | 
			
		||||
		machineFile.POST(":machineId/files/:fileId/create-file", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(createFile).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(createFile).
 | 
			
		||||
				WithRequiredPermission(wfP).
 | 
			
		||||
				Handle(mf.CreateFile)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		uploadFile := ctx.NewLogInfo("机器-文件上传").WithSave(true)
 | 
			
		||||
		ufP := ctx.NewPermission("machine:file:upload")
 | 
			
		||||
		uploadFile := req.NewLogInfo("机器-文件上传").WithSave(true)
 | 
			
		||||
		ufP := req.NewPermission("machine:file:upload")
 | 
			
		||||
		machineFile.POST(":machineId/files/:fileId/upload", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(uploadFile).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(uploadFile).
 | 
			
		||||
				WithRequiredPermission(ufP).
 | 
			
		||||
				Handle(mf.UploadFile)
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		removeFile := ctx.NewLogInfo("机器-删除文件or文件夹").WithSave(true)
 | 
			
		||||
		rfP := ctx.NewPermission("machine:file:rm")
 | 
			
		||||
		removeFile := req.NewLogInfo("机器-删除文件or文件夹").WithSave(true)
 | 
			
		||||
		rfP := req.NewPermission("machine:file:rm")
 | 
			
		||||
		machineFile.DELETE(":machineId/files/:fileId/remove", func(c *gin.Context) {
 | 
			
		||||
			ctx.NewReqCtxWithGin(c).WithLog(removeFile).
 | 
			
		||||
			req.NewCtxWithGin(c).WithLog(removeFile).
 | 
			
		||||
				WithRequiredPermission(rfP).
 | 
			
		||||
				Handle(mf.RemoveFile)
 | 
			
		||||
		})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user