chore: add ansible backend docker frontend-prep
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gestion/db"
|
||||
"gestion/models"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// --------------------------------------------
|
||||
// MEDIA
|
||||
// --------------------------------------------
|
||||
|
||||
func GetMediaForProduct(productID int) ([]models.Media, error) {
|
||||
return db.DB.GetMediaByProductID(productID)
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
// FILES NAMES
|
||||
// --------------------------------------------
|
||||
|
||||
func GenerateUniqueFileName(productName string, originalFileName string) string {
|
||||
randomString := fmt.Sprintf("%d", rand.Intn(1000000))
|
||||
ext := filepath.Ext(originalFileName)
|
||||
return fmt.Sprintf("%s_%s%s", productName, randomString, ext)
|
||||
}
|
||||
|
||||
func DeleteOldFile(filePath string) error {
|
||||
return os.Remove(filePath)
|
||||
}
|
||||
Reference in New Issue
Block a user