update
This commit is contained in:
parent
a2cdb34bc3
commit
849d353736
|
|
@ -22,11 +22,14 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
|
||||
type productsService struct {
|
||||
Repo repository.ProductsRepository
|
||||
Log zerolog.Logger
|
||||
|
|
@ -98,17 +101,35 @@ func (_i *productsService) Create(c *fiber.Ctx, req request.ProductsCreateReques
|
|||
req.ThumbnailPath = filePath
|
||||
}
|
||||
|
||||
// 🔥 CONVERT REQUEST KE ENTITY
|
||||
productEntity := req.ToEntity()
|
||||
|
||||
// 🔥 FIX COLORS (INI INTI MASALAH KAMU)
|
||||
var colors []string
|
||||
for _, c := range req.Colors {
|
||||
if c.Name != "" {
|
||||
colors = append(colors, c.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if len(colors) > 0 {
|
||||
bytes, _ := json.Marshal(colors)
|
||||
colorStr := string(bytes)
|
||||
productEntity.Colors = &colorStr
|
||||
}
|
||||
|
||||
|
||||
// SET DEFAULT ACTIVE
|
||||
isActive := true
|
||||
productEntity.IsActive = &isActive
|
||||
|
||||
// 🔥 SIMPAN KE DATABASE
|
||||
productEntity, err = _i.Repo.Create(productEntity)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
host := _i.Cfg.App.Domain
|
||||
|
||||
product = mapper.ProductsResponseMapper(productEntity, host)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ enable = true
|
|||
|
||||
[middleware.limiter]
|
||||
enable = false
|
||||
max = 20
|
||||
max = 500
|
||||
expiration_seconds = 60
|
||||
|
||||
[middleware.csrf]
|
||||
|
|
|
|||
Loading…
Reference in New Issue