This commit is contained in:
2026-03-16 20:40:33 -03:00
parent 0905005543
commit e33faa687d
2 changed files with 52 additions and 18 deletions

View File

@@ -0,0 +1,23 @@
package repository
import (
"strconv"
"url-short/models"
"gorm.io/gorm"
)
func RecuperarUrl(shortUrl string, db *gorm.DB) (string, error) {
var url models.Url
i, err := strconv.ParseInt(shortUrl, 10, 64);
if err != nil {
return "", err
}
result := db.Where(&models.Url{Shorturl: i}).First(&url)
if result.Error != nil {
return "", result.Error
}
return url.Longurl, nil
}