add product_item

This commit is contained in:
王性驊 2025-04-10 15:47:07 +08:00
parent 4806eea021
commit 61870ec7a2
6 changed files with 12 additions and 6 deletions

View File

@ -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,
})

View File

@ -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,
})

View File

@ -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,
}
}

View File

@ -45,6 +45,7 @@ type ProductItemQueryParams struct {
ReferenceID *string // 對應參照的ID
IsFree *bool // 是否為免費品項(贈品)
Status *product.ItemStatus // 商品狀態
IsUnlimited *bool
}
type ProductUpdateItem struct {
Name *string // 名稱

View File

@ -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)

View File

@ -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)