Private
Public Access
feat: implementado un patron de repository
This commit is contained in:
1 parent
03df1c5264
commit
785bc7db6b
18 files changed
+505
-160
No files matched your search
@@ -4,7 +4,6 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repuestera_back/config"
|
||||
"repuestera_back/dto"
|
||||
models_seguridad "repuestera_back/models/seguridad"
|
||||
|
||||
@@ -21,8 +20,7 @@ func Register(c *gin.Context) {
|
||||
|
||||
email := strings.ToLower(strings.TrimSpace(req.Email))
|
||||
|
||||
var existing models_seguridad.Usuario
|
||||
if err := config.DB.Where("LOWER(email) = ?", email).First(&existing).Error; err == nil {
|
||||
if _, err := usuarioRepo.ObtenerPorEmail(email); err == nil {
|
||||
c.JSON(http.StatusConflict, gin.H{"error": "El email ya esta registrado"})
|
||||
return
|
||||
}
|
||||
@@ -39,7 +37,7 @@ func Register(c *gin.Context) {
|
||||
Name: req.Name,
|
||||
}
|
||||
|
||||
if err := config.DB.Create(&user).Error; err != nil {
|
||||
if err := usuarioRepo.Crear(&user); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user