mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	refactor: 机器文件操作优化
This commit is contained in:
		@@ -76,7 +76,6 @@ func (m *MachineFile) CreateFile(rc *req.Ctx) {
 | 
			
		||||
		m.MachineFileApp.CreateFile(fid, form.Path)
 | 
			
		||||
		rc.ReqParam = fmt.Sprintf("%s -> 创建文件: %s", mi.GetLogDesc(), path)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MachineFile) ReadFileContent(rc *req.Ctx) {
 | 
			
		||||
@@ -121,12 +120,10 @@ func (m *MachineFile) GetDirEntry(rc *req.Ctx) {
 | 
			
		||||
	fisVO := make([]vo.MachineFileInfo, 0)
 | 
			
		||||
	for _, fi := range fis {
 | 
			
		||||
		fisVO = append(fisVO, vo.MachineFileInfo{
 | 
			
		||||
			Name:    fi.Name(),
 | 
			
		||||
			Size:    fi.Size(),
 | 
			
		||||
			Path:    readPath + fi.Name(),
 | 
			
		||||
			Type:    getFileType(fi.Mode()),
 | 
			
		||||
			Mode:    fi.Mode().String(),
 | 
			
		||||
			ModTime: fi.ModTime().Format("2006-01-02 15:04:05"),
 | 
			
		||||
			Name: fi.Name(),
 | 
			
		||||
			Size: fi.Size(),
 | 
			
		||||
			Path: readPath + fi.Name(),
 | 
			
		||||
			Type: getFileType(fi.Mode()),
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	sort.Sort(vo.MachineFileInfos(fisVO))
 | 
			
		||||
@@ -134,6 +131,22 @@ func (m *MachineFile) GetDirEntry(rc *req.Ctx) {
 | 
			
		||||
	rc.ReqParam = fmt.Sprintf("path: %s", readPath)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MachineFile) GetDirSize(rc *req.Ctx) {
 | 
			
		||||
	g := rc.GinCtx
 | 
			
		||||
	fid := GetMachineFileId(g)
 | 
			
		||||
	readPath := g.Query("path")
 | 
			
		||||
 | 
			
		||||
	rc.ResData = m.MachineFileApp.GetDirSize(fid, readPath)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MachineFile) GetFileStat(rc *req.Ctx) {
 | 
			
		||||
	g := rc.GinCtx
 | 
			
		||||
	fid := GetMachineFileId(g)
 | 
			
		||||
	readPath := g.Query("path")
 | 
			
		||||
 | 
			
		||||
	rc.ResData = m.MachineFileApp.FileStat(fid, readPath)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *MachineFile) WriteFileContent(rc *req.Ctx) {
 | 
			
		||||
	g := rc.GinCtx
 | 
			
		||||
	fid := GetMachineFileId(g)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user