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))
|
||||
for _, fItem := range item.CustomFields {
|
||||
f = append(f, &product.CustomField{
|
||||
c = append(c, &product.CustomField{
|
||||
Key: fItem.Key,
|
||||
Value: fItem.Value,
|
||||
})
|
||||
|
|
|
@ -96,7 +96,7 @@ func (l *ListByProductIdLogic) ListByProductId(in *PB.ListProductItemRequest) (*
|
|||
// 運費
|
||||
c := make([]*PB.CustomField, 0, len(item.CustomFields))
|
||||
for _, fItem := range item.CustomFields {
|
||||
f = append(f, &PB.CustomField{
|
||||
c = append(c, &PB.CustomField{
|
||||
Key: fItem.Key,
|
||||
Value: fItem.Value,
|
||||
})
|
||||
|
|
|
@ -20,10 +20,11 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
CategoryUseCase: MustCategory(c),
|
||||
TagsUseCase: MustTags(c),
|
||||
KYCUseCase: MustKYC(c),
|
||||
Config: c,
|
||||
CategoryUseCase: MustCategory(c),
|
||||
TagsUseCase: MustTags(c),
|
||||
KYCUseCase: MustKYC(c),
|
||||
ProductItemUseCase: MustProductItem(c),
|
||||
Config: c,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ type ProductItemQueryParams struct {
|
|||
ReferenceID *string // 對應參照的ID
|
||||
IsFree *bool // 是否為免費品項(贈品)
|
||||
Status *product.ItemStatus // 商品狀態
|
||||
IsUnlimited *bool
|
||||
}
|
||||
type ProductUpdateItem struct {
|
||||
Name *string // 名稱
|
||||
|
|
|
@ -235,6 +235,9 @@ func (repo *ProductItemRepository) ListProductItem(ctx context.Context, param re
|
|||
if param.Status != nil {
|
||||
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)
|
||||
|
|
|
@ -336,6 +336,7 @@ func (use *ProductItemUseCase) List(ctx context.Context, filter usecase.QueryPro
|
|||
ReferenceID: filter.ReferenceID,
|
||||
IsFree: filter.IsFree,
|
||||
Status: filter.Status,
|
||||
IsUnlimited: filter.IsUnLimit,
|
||||
// 注意:若需要依 IsUnLimit 過濾,需擴充 repository.ProductItemQueryParams 結構
|
||||
}
|
||||
entities, total, err := use.ProductItemUseCaseParam.ProductItems.ListProductItem(ctx, repoQuery)
|
||||
|
|
Loading…
Reference in New Issue