From 99aa77e60aacfcc944f535b1b3bc21dba0d9c6e4 Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Tue, 3 Feb 2026 18:44:24 +0800 Subject: [PATCH] add category --- app/database/entity/galleries.entity.go | 2 ++ app/module/galleries/mapper/galleries.mapper.go | 1 + app/module/galleries/request/galleries.request.go | 5 +++++ app/module/galleries/response/galleries.response.go | 1 + app/module/products/service/products.service.go | 4 +--- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/database/entity/galleries.entity.go b/app/database/entity/galleries.entity.go index b2ec383..3bfb26b 100644 --- a/app/database/entity/galleries.entity.go +++ b/app/database/entity/galleries.entity.go @@ -13,5 +13,7 @@ type Galleries struct { IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` + Category string `json:"category" db:"category"` + } diff --git a/app/module/galleries/mapper/galleries.mapper.go b/app/module/galleries/mapper/galleries.mapper.go index cbeb068..d42e726 100644 --- a/app/module/galleries/mapper/galleries.mapper.go +++ b/app/module/galleries/mapper/galleries.mapper.go @@ -13,6 +13,7 @@ func GalleriesResponseMapper(gallery *entity.Galleries, host string) *res.Galler response := &res.GalleriesResponse{ ID: gallery.ID, Title: gallery.Title, + Category: gallery.Category, Description: gallery.Description, ThumbnailPath: gallery.ThumbnailPath, StatusId: gallery.StatusId, diff --git a/app/module/galleries/request/galleries.request.go b/app/module/galleries/request/galleries.request.go index c897b62..d00bb50 100644 --- a/app/module/galleries/request/galleries.request.go +++ b/app/module/galleries/request/galleries.request.go @@ -33,6 +33,8 @@ type GalleriesCreateRequest struct { Title string `json:"title" validate:"required"` Description *string `json:"description"` ThumbnailPath *string `json:"thumbnail_path"` + Category string `form:"category" json:"category" validate:"required"` + } func (req GalleriesCreateRequest) ToEntity() *entity.Galleries { @@ -47,9 +49,12 @@ type GalleriesUpdateRequest struct { Title *string `json:"title"` Description *string `json:"description"` ThumbnailPath *string `json:"thumbnail_path"` + Category string `form:"category" json:"category" validate:"required"` IsActive *bool `json:"is_active"` } + + func (req GalleriesUpdateRequest) ToEntity() *entity.Galleries { return &entity.Galleries{ Title: getStringValue(req.Title), diff --git a/app/module/galleries/response/galleries.response.go b/app/module/galleries/response/galleries.response.go index a169b79..0372a64 100644 --- a/app/module/galleries/response/galleries.response.go +++ b/app/module/galleries/response/galleries.response.go @@ -7,6 +7,7 @@ import ( type GalleriesResponse struct { ID uint `json:"id"` Title string `json:"title"` + Category string `json:"category"` Description *string `json:"description"` ThumbnailPath *string `json:"thumbnail_path"` ThumbnailUrl *string `json:"thumbnail_url"` diff --git a/app/module/products/service/products.service.go b/app/module/products/service/products.service.go index 485ec60..6f13fb7 100644 --- a/app/module/products/service/products.service.go +++ b/app/module/products/service/products.service.go @@ -208,9 +208,7 @@ func (_i *productsService) Create(c *fiber.Ctx, req request.ProductsCreateReques // 🔥 CONVERT REQUEST KE ENTITY productEntity := req.ToEntity() - // =============================== - // 3️⃣ 🔥 HANDLE COLORS + IMAGE - // =============================== + form, _ := c.MultipartForm() colorFiles := form.File["color_images"] colorsStr := c.FormValue("colors")