feat: 新增linux文件夹创建&删除&其他优化

This commit is contained in:
meilin.huang
2022-07-04 20:21:24 +08:00
parent b88923a128
commit 729a3d7028
13 changed files with 162 additions and 69 deletions

View File

@@ -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"` //数据库名

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {