Migrate all methods in the model package to the service package

This commit is contained in:
Granty1
2020-04-08 11:07:27 +08:00
parent 2c35adaffc
commit 5d222585dd
49 changed files with 1348 additions and 1261 deletions

View File

@@ -2,6 +2,11 @@ package utils
import "os"
// @title PathExists
// @description 文件目录是否存在
// @auth 2020/04/05 20:22
// @param path string
// @return err error
func PathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
@@ -12,3 +17,31 @@ func PathExists(path string) (bool, error) {
}
return false, err
}
// @title createDir
// @description 批量创建文件夹
// @auth 2020/04/05 20:22
// @param dirs string
// @return err error
func CreateDir(dirs ...string) (err error) {
for _, v := range dirs {
exist, err := PathExists(v)
if err != nil {
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
return err
}
if exist {
//log.L.Info(fmt.Sprintf("has dir![%v]\n"+_dir))
} else {
//log.L.Info(fmt.Sprintf("no dir![%v]\n"+_dir))
// 创建文件夹
err = os.Mkdir(v, os.ModePerm)
if err != nil {
//log.L.Error(fmt.Sprintf("mkdir error![%v]\n",err))
} else {
//log.L.Info("mkdir success!\n")
}
}
}
return err
}