fix: usar Updates(map) en lugar de Updates(struct) para evitar error id en PostgreSQL
This commit is contained in:
+10
-1
@@ -59,7 +59,16 @@ func CreateCliente(c Cliente) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateCliente(c Cliente) error {
|
func UpdateCliente(c Cliente) error {
|
||||||
return app.Http.Database.DB.Model(&c).Updates(c).Error
|
return app.Http.Database.DB.Model(&Cliente{}).Where("id = ?", c.ID).Updates(map[string]interface{}{
|
||||||
|
"nombre": c.Nombre,
|
||||||
|
"empresa": c.Empresa,
|
||||||
|
"email": c.Email,
|
||||||
|
"email_cc": c.EmailCC,
|
||||||
|
"telefono": c.Telefono,
|
||||||
|
"documento": c.Documento,
|
||||||
|
"notas": c.Notas,
|
||||||
|
"activo": c.Activo,
|
||||||
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteCliente(id uint) error {
|
func DeleteCliente(id uint) error {
|
||||||
|
|||||||
+10
-1
@@ -86,7 +86,16 @@ func CreateContrato(c Contrato) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateContrato(c Contrato) error {
|
func UpdateContrato(c Contrato) error {
|
||||||
return app.Http.Database.DB.Model(&c).Updates(c).Error
|
return app.Http.Database.DB.Model(&Contrato{}).Where("id = ?", c.ID).Updates(map[string]interface{}{
|
||||||
|
"cliente_id": c.ClienteID,
|
||||||
|
"servicio_id": c.ServicioID,
|
||||||
|
"fecha_inicio": c.FechaInicio,
|
||||||
|
"fecha_vencimiento": c.FechaVencimiento,
|
||||||
|
"precio_acordado": c.PrecioAcordado,
|
||||||
|
"estado": c.Estado,
|
||||||
|
"auto_renovar": c.AutoRenovar,
|
||||||
|
"notas": c.Notas,
|
||||||
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteContrato(id uint) error {
|
func DeleteContrato(id uint) error {
|
||||||
|
|||||||
@@ -57,7 +57,15 @@ func CreateServicio(s Servicio) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateServicio(s Servicio) error {
|
func UpdateServicio(s Servicio) error {
|
||||||
return app.Http.Database.DB.Model(&s).Updates(s).Error
|
return app.Http.Database.DB.Model(&Servicio{}).Where("id = ?", s.ID).Updates(map[string]interface{}{
|
||||||
|
"nombre": s.Nombre,
|
||||||
|
"descripcion": s.Descripcion,
|
||||||
|
"precio": s.Precio,
|
||||||
|
"moneda": s.Moneda,
|
||||||
|
"tipo": s.Tipo,
|
||||||
|
"periodicidad": s.Periodicidad,
|
||||||
|
"activo": s.Activo,
|
||||||
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteServicio(id uint) error {
|
func DeleteServicio(id uint) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user