first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

34
pkg/tools/path.go Normal file
View File

@ -0,0 +1,34 @@
package tools
import (
"github.com/spf13/viper"
"os"
"path"
"path/filepath"
)
const (
urlPre = "/api/v1/attachment"
)
func Mkdir(basePath string, folderName string) string {
folderPath := filepath.Join(basePath, folderName)
_ = os.MkdirAll(folderPath, os.ModePerm)
return folderPath
}
func BasePath() string {
return viper.GetString("attachment.path")
}
func UrlBasePath() string {
return "/static"
}
func URLPath(filePath string) string {
return filepath.Join("/", UrlBasePath(), filePath)
}
func AttachmentUrl(relative string) string {
return path.Join(urlPre, relative)
}