add product_item
This commit is contained in:
parent
4806eea021
commit
61870ec7a2
|
@ -72,7 +72,7 @@ func (l *GetLogic) Get(in *product.GetProductItemRequest) (*product.ProductItem,
|
||||||
// 運費
|
// 運費
|
||||||
c := make([]*product.CustomField, 0, len(item.CustomFields))
|
c := make([]*product.CustomField, 0, len(item.CustomFields))
|
||||||
for _, fItem := range item.CustomFields {
|
for _, fItem := range item.CustomFields {
|
||||||
f = append(f, &product.CustomField{
|
c = append(c, &product.CustomField{
|
||||||
Key: fItem.Key,
|
Key: fItem.Key,
|
||||||
Value: fItem.Value,
|
Value: fItem.Value,
|
||||||
})
|
})
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (l *ListByProductIdLogic) ListByProductId(in *PB.ListProductItemRequest) (*
|
||||||
// 運費
|
// 運費
|
||||||
c := make([]*PB.CustomField, 0, len(item.CustomFields))
|
c := make([]*PB.CustomField, 0, len(item.CustomFields))
|
||||||
for _, fItem := range item.CustomFields {
|
for _, fItem := range item.CustomFields {
|
||||||
f = append(f, &PB.CustomField{
|
c = append(c, &PB.CustomField{
|
||||||
Key: fItem.Key,
|
Key: fItem.Key,
|
||||||
Value: fItem.Value,
|
Value: fItem.Value,
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,6 +23,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
CategoryUseCase: MustCategory(c),
|
CategoryUseCase: MustCategory(c),
|
||||||
TagsUseCase: MustTags(c),
|
TagsUseCase: MustTags(c),
|
||||||
KYCUseCase: MustKYC(c),
|
KYCUseCase: MustKYC(c),
|
||||||
|
ProductItemUseCase: MustProductItem(c),
|
||||||
Config: c,
|
Config: c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ type ProductItemQueryParams struct {
|
||||||
ReferenceID *string // 對應參照的ID
|
ReferenceID *string // 對應參照的ID
|
||||||
IsFree *bool // 是否為免費品項(贈品)
|
IsFree *bool // 是否為免費品項(贈品)
|
||||||
Status *product.ItemStatus // 商品狀態
|
Status *product.ItemStatus // 商品狀態
|
||||||
|
IsUnlimited *bool
|
||||||
}
|
}
|
||||||
type ProductUpdateItem struct {
|
type ProductUpdateItem struct {
|
||||||
Name *string // 名稱
|
Name *string // 名稱
|
||||||
|
|
|
@ -235,6 +235,9 @@ func (repo *ProductItemRepository) ListProductItem(ctx context.Context, param re
|
||||||
if param.Status != nil {
|
if param.Status != nil {
|
||||||
filter["status"] = *param.Status
|
filter["status"] = *param.Status
|
||||||
}
|
}
|
||||||
|
if param.IsUnlimited != nil {
|
||||||
|
filter["is_un_limit"] = *param.IsUnlimited
|
||||||
|
}
|
||||||
|
|
||||||
// 設置排序選項
|
// 設置排序選項
|
||||||
opts := options.Find().SetSkip((param.PageIndex - 1) * param.PageSize).SetLimit(param.PageSize)
|
opts := options.Find().SetSkip((param.PageIndex - 1) * param.PageSize).SetLimit(param.PageSize)
|
||||||
|
|
|
@ -336,6 +336,7 @@ func (use *ProductItemUseCase) List(ctx context.Context, filter usecase.QueryPro
|
||||||
ReferenceID: filter.ReferenceID,
|
ReferenceID: filter.ReferenceID,
|
||||||
IsFree: filter.IsFree,
|
IsFree: filter.IsFree,
|
||||||
Status: filter.Status,
|
Status: filter.Status,
|
||||||
|
IsUnlimited: filter.IsUnLimit,
|
||||||
// 注意:若需要依 IsUnLimit 過濾,需擴充 repository.ProductItemQueryParams 結構
|
// 注意:若需要依 IsUnLimit 過濾,需擴充 repository.ProductItemQueryParams 結構
|
||||||
}
|
}
|
||||||
entities, total, err := use.ProductItemUseCaseParam.ProductItems.ListProductItem(ctx, repoQuery)
|
entities, total, err := use.ProductItemUseCaseParam.ProductItems.ListProductItem(ctx, repoQuery)
|
||||||
|
|
Loading…
Reference in New Issue