mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-04-19 02:35:20 +08:00
feat: 新增linux文件夹创建&删除&其他优化
This commit is contained in:
@@ -15,6 +15,13 @@ type DbForm struct {
|
||||
EnvId uint64 `binding:"required" json:"envId"`
|
||||
}
|
||||
|
||||
type DbSqlSaveForm struct {
|
||||
Name string
|
||||
Sql string `binding:"required"`
|
||||
Type int `binding:"required"`
|
||||
Db string `binding:"required"`
|
||||
}
|
||||
|
||||
// 数据库SQL执行表单
|
||||
type DbSqlExecForm struct {
|
||||
Db string `binding:"required" json:"db"` //数据库名
|
||||
|
||||
@@ -38,11 +38,9 @@ type MachineScriptForm struct {
|
||||
Script string `binding:"required"`
|
||||
}
|
||||
|
||||
type DbSqlSaveForm struct {
|
||||
Name string
|
||||
Sql string `binding:"required"`
|
||||
Type int `binding:"required"`
|
||||
Db string `binding:"required"`
|
||||
type MachineCreateFileForm struct {
|
||||
Path string `binding:"required"`
|
||||
Type string `binding:"required"`
|
||||
}
|
||||
|
||||
type MachineFileUpdateForm struct {
|
||||
@@ -60,6 +60,22 @@ func (m *MachineFile) DeleteFile(rc *ctx.ReqCtx) {
|
||||
|
||||
/*** sftp相关操作 */
|
||||
|
||||
func (m *MachineFile) CreateFile(rc *ctx.ReqCtx) {
|
||||
g := rc.GinCtx
|
||||
fid := GetMachineFileId(g)
|
||||
|
||||
form := new(form.MachineCreateFileForm)
|
||||
ginx.BindJsonAndValid(g, form)
|
||||
path := form.Path
|
||||
|
||||
if form.Type == dir {
|
||||
m.MachineFileApp.MkDir(fid, form.Path)
|
||||
} else {
|
||||
m.MachineFileApp.CreateFile(fid, form.Path)
|
||||
}
|
||||
rc.ReqParam = fmt.Sprintf("path: %s, type: %s", path, form.Type)
|
||||
}
|
||||
|
||||
func (m *MachineFile) ReadFileContent(rc *ctx.ReqCtx) {
|
||||
g := rc.GinCtx
|
||||
fid := GetMachineFileId(g)
|
||||
@@ -104,6 +120,7 @@ func (m *MachineFile) GetDirEntry(rc *ctx.ReqCtx) {
|
||||
Size: fi.Size(),
|
||||
Path: readPath + fi.Name(),
|
||||
Type: getFileType(fi.Mode()),
|
||||
Mode: fi.Mode().String(),
|
||||
})
|
||||
}
|
||||
rc.ResData = fisVO
|
||||
@@ -155,7 +172,6 @@ func (m *MachineFile) UploadFile(rc *ctx.ReqCtx) {
|
||||
func (m *MachineFile) RemoveFile(rc *ctx.ReqCtx) {
|
||||
g := rc.GinCtx
|
||||
fid := GetMachineFileId(g)
|
||||
// mid := GetMachineId(g)
|
||||
path := g.Query("path")
|
||||
|
||||
m.MachineFileApp.RemoveFile(fid, path)
|
||||
@@ -167,7 +183,10 @@ func getFileType(fm fs.FileMode) string {
|
||||
if fm.IsDir() {
|
||||
return dir
|
||||
}
|
||||
return file
|
||||
if fm.IsRegular() {
|
||||
return file
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func GetMachineFileId(g *gin.Context) uint64 {
|
||||
|
||||
@@ -56,6 +56,7 @@ type MachineFileInfo struct {
|
||||
Path string `json:"path"`
|
||||
Size int64 `json:"size"`
|
||||
Type string `json:"type"`
|
||||
Mode string `json:"mode"`
|
||||
}
|
||||
|
||||
type RoleVO struct {
|
||||
|
||||
Reference in New Issue
Block a user