Private
Public Access
falta testeo
This commit is contained in:
1 parent
9205fea8d8
commit
61ca620c8e
50 files changed
+3061
-1112
No files matched your search
@@ -1,11 +1,18 @@
|
||||
package stock
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
dto "repuestera_back/dto/Stock"
|
||||
models_logs "repuestera_back/models/logs"
|
||||
"repuestera_back/repositorios"
|
||||
"repuestera_back/utils"
|
||||
)
|
||||
|
||||
func ActualizarObservacion(c *gin.Context) {
|
||||
@@ -13,16 +20,33 @@ func ActualizarObservacion(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var data dto.ObservacionDto
|
||||
if err := c.ShouldBindJSON(&data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resultado, err := nuevoServicio(c).Comentar(id, data.Observacion)
|
||||
texto := strings.TrimSpace(data.Observacion)
|
||||
if err := validarObservacion(texto); err != nil {
|
||||
responderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
repos := repositorios.ObtenerRepositorios(c)
|
||||
resultado, err := repos.Stock.ActualizarObservacion(id, texto)
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
responderError(c, ErrStockNoEncontrado)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
responderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
registrarLog(repos, utils.EmpresaID(c), c.GetUint("userID"), "COMENTAR_STOCK", []models_logs.LogDetalle{
|
||||
{Columna: "stockId", ValorNuevo: fmt.Sprintf("%d", id)},
|
||||
{Columna: "observacion", ValorNuevo: texto},
|
||||
})
|
||||
c.JSON(http.StatusOK, resultado)
|
||||
}
|
||||
Reference in new issue
Block a user