Update proyecto_controller.go
This commit is contained in:
@@ -66,7 +66,7 @@ func LoadProyectos(c *fiber.Ctx) error {
|
||||
|
||||
func CreateProyecto(c *fiber.Ctx) error {
|
||||
type Req struct {
|
||||
ClienteID uint `json:"cliente_id"`
|
||||
ClienteID string `json:"cliente_id"`
|
||||
Nombre string `json:"nombre"`
|
||||
Slug string `json:"slug"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
@@ -77,7 +77,8 @@ func CreateProyecto(c *fiber.Ctx) error {
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
if req.ClienteID == 0 || strings.TrimSpace(req.Nombre) == "" {
|
||||
clienteID, _ := strconv.ParseUint(req.ClienteID, 10, 64)
|
||||
if clienteID == 0 || strings.TrimSpace(req.Nombre) == "" {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "cliente y nombre son requeridos"})
|
||||
}
|
||||
if req.Slug == "" {
|
||||
@@ -90,7 +91,7 @@ func CreateProyecto(c *fiber.Ctx) error {
|
||||
req.Estado = "activo"
|
||||
}
|
||||
p := &models.Proyecto{
|
||||
ClienteID: req.ClienteID,
|
||||
ClienteID: uint(clienteID),
|
||||
Nombre: req.Nombre,
|
||||
Slug: req.Slug,
|
||||
Descripcion: req.Descripcion,
|
||||
@@ -109,7 +110,7 @@ func UpdateProyecto(c *fiber.Ctx) error {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
type Req struct {
|
||||
ClienteID uint `json:"cliente_id"`
|
||||
ClienteID string `json:"cliente_id"`
|
||||
Nombre string `json:"nombre"`
|
||||
Slug string `json:"slug"`
|
||||
Descripcion string `json:"descripcion"`
|
||||
@@ -121,8 +122,9 @@ func UpdateProyecto(c *fiber.Ctx) error {
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
updateClienteID, _ := strconv.ParseUint(req.ClienteID, 10, 64)
|
||||
p := &models.Proyecto{
|
||||
ClienteID: req.ClienteID,
|
||||
ClienteID: uint(updateClienteID),
|
||||
Nombre: req.Nombre,
|
||||
Slug: req.Slug,
|
||||
Descripcion: req.Descripcion,
|
||||
|
||||
Reference in New Issue
Block a user