mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
feat(product): update product status handling and enhance category tree response logging
This commit is contained in:
parent
891bae4742
commit
ba95c9079f
@ -468,9 +468,16 @@ func (s *ProductServer) ListCategoryTree(ctx context.Context, req *productv1.Lis
|
||||
dbSpan.SetAttributes(attribute.Int("category.result_count", len(categories)))
|
||||
observability.IncCategoryTreeLists()
|
||||
|
||||
return &productv1.ListCategoryTreeResponse{
|
||||
resp := &productv1.ListCategoryTreeResponse{
|
||||
Categories: buildCategoryTree(categories),
|
||||
}, nil
|
||||
}
|
||||
if payload, marshalErr := (protojson.MarshalOptions{UseProtoNames: true, EmitUnpopulated: true}).Marshal(resp); marshalErr != nil {
|
||||
s.observer.Logger(ctx).Warn("marshal category tree response for logging failed", zap.Error(marshalErr))
|
||||
} else {
|
||||
s.observer.Logger(ctx).Info("list category tree response", zap.ByteString("response", payload))
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// CreateCategoryTree creates a top-level category and optional second-level categories.
|
||||
@ -1094,6 +1101,9 @@ func productFromCreateRequest(req *productv1.CreateProductRequest) (repository.P
|
||||
}
|
||||
|
||||
statusValue := req.GetStatus()
|
||||
if statusValue == productv1.ProductStatus_PRODUCT_STATUS_NOT_FOUND {
|
||||
statusValue = productv1.ProductStatus_PRODUCT_STATUS_INVENTORY
|
||||
}
|
||||
if statusValue != productv1.ProductStatus_PRODUCT_STATUS_INVENTORY &&
|
||||
statusValue != productv1.ProductStatus_PRODUCT_STATUS_ON_SALE &&
|
||||
statusValue != productv1.ProductStatus_PRODUCT_STATUS_OFF_SALE {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user