1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package stringutil
- import (
- "Cold_Logistic/internal/pkg/common/constant"
- "Cold_Logistic/internal/pkg/common/options"
- "path"
- "strconv"
- "strings"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/util/fileutil"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/util/idutil"
- )
- func GenUploadKeyPath(fileName string) (keyPath string) {
- return path.Join(options.OptInstance.Storage.ProjectPrefixPath, constant.UploadPath, fileutil.GenYYYYMMDDPath(), strconv.FormatUint(idutil.GetIntID(), 10), fileName)
- }
- func GenUploadBasePath(suffix string) string {
- return path.Join(options.OptInstance.Storage.ProjectPrefixPath, constant.UploadPath, suffix)
- }
- func GenExportBasePath(suffix string) string {
- return path.Join(options.OptInstance.Storage.ProjectPrefixPath, constant.ExportPath, suffix)
- }
- func GenUploadKeyPathWithCategory(fileCategory, fileName string) (keyPath string) {
- fileCategory = strings.TrimSpace(fileCategory)
- if len(fileCategory) == 0 {
- return GenUploadKeyPath(fileName)
- }
- return path.Join(options.OptInstance.Storage.ProjectPrefixPath, constant.UploadPath, fileCategory, fileutil.GenYYYYMMDDPath(), strconv.FormatUint(idutil.GetIntID(), 10), fileName)
- }
- func GenExcelKeyPath(fileName string) (keyPath string) {
- return path.Join(options.OptInstance.Storage.ProjectPrefixPath, constant.ExcelPath, fileutil.GenYYYYMMDDPath(), strconv.FormatUint(idutil.GetIntID(), 10), fileName)
- }
- func GenLocalUploadPath(fileName string) (keyPath string) {
- return path.Join(options.OptInstance.Storage.LocalStorageOptions.RootFilePath, fileutil.GenYYYYMMDDPath(), strconv.FormatUint(idutil.GetIntID(), 10), fileName)
- }
- func GenLocalExportPath(fileCategory, fileName string) (keyPath string) {
- return path.Join(options.OptInstance.Storage.LocalStorageOptions.RootFilePath, constant.ExportPath, fileCategory, fileutil.GenYYYYMMDDPath(), strconv.FormatUint(idutil.GetIntID(), 10), fileName)
- }
|