add category
This commit is contained in:
parent
53b16cc0bc
commit
99aa77e60a
|
|
@ -13,5 +13,7 @@ type Galleries struct {
|
||||||
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||||
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
||||||
|
Category string `json:"category" db:"category"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ func GalleriesResponseMapper(gallery *entity.Galleries, host string) *res.Galler
|
||||||
response := &res.GalleriesResponse{
|
response := &res.GalleriesResponse{
|
||||||
ID: gallery.ID,
|
ID: gallery.ID,
|
||||||
Title: gallery.Title,
|
Title: gallery.Title,
|
||||||
|
Category: gallery.Category,
|
||||||
Description: gallery.Description,
|
Description: gallery.Description,
|
||||||
ThumbnailPath: gallery.ThumbnailPath,
|
ThumbnailPath: gallery.ThumbnailPath,
|
||||||
StatusId: gallery.StatusId,
|
StatusId: gallery.StatusId,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ type GalleriesCreateRequest struct {
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
ThumbnailPath *string `json:"thumbnail_path"`
|
ThumbnailPath *string `json:"thumbnail_path"`
|
||||||
|
Category string `form:"category" json:"category" validate:"required"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req GalleriesCreateRequest) ToEntity() *entity.Galleries {
|
func (req GalleriesCreateRequest) ToEntity() *entity.Galleries {
|
||||||
|
|
@ -47,9 +49,12 @@ type GalleriesUpdateRequest struct {
|
||||||
Title *string `json:"title"`
|
Title *string `json:"title"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
ThumbnailPath *string `json:"thumbnail_path"`
|
ThumbnailPath *string `json:"thumbnail_path"`
|
||||||
|
Category string `form:"category" json:"category" validate:"required"`
|
||||||
IsActive *bool `json:"is_active"`
|
IsActive *bool `json:"is_active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (req GalleriesUpdateRequest) ToEntity() *entity.Galleries {
|
func (req GalleriesUpdateRequest) ToEntity() *entity.Galleries {
|
||||||
return &entity.Galleries{
|
return &entity.Galleries{
|
||||||
Title: getStringValue(req.Title),
|
Title: getStringValue(req.Title),
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
type GalleriesResponse struct {
|
type GalleriesResponse struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
Category string `json:"category"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
ThumbnailPath *string `json:"thumbnail_path"`
|
ThumbnailPath *string `json:"thumbnail_path"`
|
||||||
ThumbnailUrl *string `json:"thumbnail_url"`
|
ThumbnailUrl *string `json:"thumbnail_url"`
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,7 @@ func (_i *productsService) Create(c *fiber.Ctx, req request.ProductsCreateReques
|
||||||
// 🔥 CONVERT REQUEST KE ENTITY
|
// 🔥 CONVERT REQUEST KE ENTITY
|
||||||
productEntity := req.ToEntity()
|
productEntity := req.ToEntity()
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// 3️⃣ 🔥 HANDLE COLORS + IMAGE
|
|
||||||
// ===============================
|
|
||||||
form, _ := c.MultipartForm()
|
form, _ := c.MultipartForm()
|
||||||
colorFiles := form.File["color_images"]
|
colorFiles := form.File["color_images"]
|
||||||
colorsStr := c.FormValue("colors")
|
colorsStr := c.FormValue("colors")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue