update
This commit is contained in:
parent
b2dc684ade
commit
3a86251fab
|
|
@ -11,6 +11,7 @@ type Products struct {
|
|||
Price *string `json:"price" gorm:"type:varchar"`
|
||||
ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"`
|
||||
Colors *string `json:"colors" gorm:"type:text"` // JSON array stored as text
|
||||
Status *string `json:"status" gorm:"type:varchar"`
|
||||
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()"`
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
_ "jaecoo-be/utils/response" // 🔥 INI KUNCINYA
|
||||
utilRes "jaecoo-be/utils/response"
|
||||
utilVal "jaecoo-be/utils/validator"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ func ProductsResponseMapper(product *entity.Products, host string) *res.Products
|
|||
Price: product.Price,
|
||||
ThumbnailPath: product.ThumbnailPath,
|
||||
Colors: colors,
|
||||
Status: product.Status,
|
||||
IsActive: product.IsActive,
|
||||
CreatedAt: product.CreatedAt,
|
||||
UpdatedAt: product.UpdatedAt,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ func (_i *productsRepository) GetAll(req request.ProductsQueryRequest) (products
|
|||
query = query.Where("variant = ?", *req.Variant)
|
||||
}
|
||||
|
||||
if req.Status != nil && *req.Status != "" {
|
||||
query = query.Where("status = ?", *req.Status)
|
||||
}
|
||||
|
||||
query = query.Where("is_active = ?", true)
|
||||
|
||||
query.Count(&count)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ import (
|
|||
type ProductsQueryRequest struct {
|
||||
Title *string `json:"title"`
|
||||
Variant *string `json:"variant"`
|
||||
Status *string `json:"status"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type ProductsQueryRequestContext struct {
|
||||
Title string `json:"title"`
|
||||
Variant string `json:"variant"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func (req ProductsQueryRequestContext) ToParamRequest() ProductsQueryRequest {
|
||||
|
|
@ -26,6 +28,9 @@ func (req ProductsQueryRequestContext) ToParamRequest() ProductsQueryRequest {
|
|||
if variant := req.Variant; variant != "" {
|
||||
request.Variant = &variant
|
||||
}
|
||||
if status := req.Status; status != "" {
|
||||
request.Status = &status
|
||||
}
|
||||
|
||||
return request
|
||||
}
|
||||
|
|
@ -36,6 +41,7 @@ type ProductsCreateRequest struct {
|
|||
Price *string `json:"price"`
|
||||
ThumbnailPath *string `json:"thumbnail_path"`
|
||||
Colors []string `json:"colors"`
|
||||
Status *string `json:"status"`
|
||||
}
|
||||
|
||||
func (req ProductsCreateRequest) ToEntity() *entity.Products {
|
||||
|
|
@ -51,6 +57,7 @@ func (req ProductsCreateRequest) ToEntity() *entity.Products {
|
|||
Price: req.Price,
|
||||
ThumbnailPath: req.ThumbnailPath,
|
||||
Colors: &colorsStr,
|
||||
Status: req.Status,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +67,7 @@ type ProductsUpdateRequest struct {
|
|||
Price *string `json:"price"`
|
||||
ThumbnailPath *string `json:"thumbnail_path"`
|
||||
Colors []string `json:"colors"`
|
||||
Status *string `json:"status"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
}
|
||||
|
||||
|
|
@ -76,6 +84,7 @@ func (req ProductsUpdateRequest) ToEntity() *entity.Products {
|
|||
Price: req.Price,
|
||||
ThumbnailPath: req.ThumbnailPath,
|
||||
Colors: &colorsStr,
|
||||
Status: req.Status,
|
||||
IsActive: req.IsActive,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ type ProductsResponse struct {
|
|||
ThumbnailPath *string `json:"thumbnail_path"`
|
||||
ThumbnailUrl *string `json:"thumbnail_url"`
|
||||
Colors []string `json:"colors"`
|
||||
Status *string `json:"status"`
|
||||
IsActive *bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
|
|
|||
|
|
@ -4714,15 +4714,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/clients-test": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
"summary": "TEST CLIENTS",
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/clients/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -4703,15 +4703,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/clients-test": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
"summary": "TEST CLIENTS",
|
||||
"responses": {}
|
||||
}
|
||||
},
|
||||
"/clients/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
|
|||
|
|
@ -3892,12 +3892,6 @@ paths:
|
|||
summary: Create Clients
|
||||
tags:
|
||||
- Clients
|
||||
/clients-test:
|
||||
get:
|
||||
responses: {}
|
||||
summary: TEST CLIENTS
|
||||
tags:
|
||||
- Clients
|
||||
/clients/{id}:
|
||||
delete:
|
||||
description: API for delete Clients
|
||||
|
|
|
|||
Loading…
Reference in New Issue