Browse Source

change filemove

v_zhibsong 4 years ago
parent
commit
53733962ef
2 changed files with 9 additions and 5 deletions
  1. 4 5
      server/service/sys_auto_code.go
  2. 5 0
      server/utils/file_operations.go

+ 4 - 5
server/service/sys_auto_code.go

@@ -12,10 +12,9 @@ import (
 )
 
 type tplData struct {
-	template         *template.Template
-	locationPath     string
-	autoCodePath     string
-	autoMoveFilePath string
+	template     *template.Template
+	locationPath string
+	autoCodePath string
 }
 
 // @title    CreateTemp
@@ -99,7 +98,7 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
 		// 判断是否需要自动转移
 		for _, value := range dataList {
 			// 转移
-			err := utils.FileMove(value.locationPath, value.autoCodePath)
+			err := utils.FileMove(value.autoCodePath, utils.GetAutoPath(value.autoCodePath))
 			if err != nil {
 				return err
 			}

+ 5 - 0
server/utils/file_operations.go

@@ -59,3 +59,8 @@ func FileMove(src string, dst string) error {
 	}
 	return err
 }
+
+// GetAutoPath 根据生成路径生成移动路径
+func GetAutoPath(path string) string {
+	return filepath.Base(filepath.Dir(path))
+}