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