import org.broadleafcommerce.frameworkmapping.annotation.FrameworkGetMapping;
import org.broadleafcommerce.frameworkmapping.annotation.FrameworkMapping;
import org.broadleafcommerce.frameworkmapping.annotation.FrameworkRestController;
import org.springframework.web.bind.annotation.PathVariable;
import com.broadleafcommerce.catalog.domain.product.Product;
import com.broadleafcommerce.catalog.service.product.ProductService;
import com.broadleafcommerce.common.extension.data.DataRouteByExample;
import com.broadleafcommerce.data.tracking.core.context.ContextInfo;
import com.broadleafcommerce.data.tracking.core.context.ContextOperation;
import com.broadleafcommerce.data.tracking.core.policy.Policy;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@FrameworkRestController (1)
@FrameworkMapping("/products") (2)
@DataRouteByExample(Product.class) (3)
@RequiredArgsConstructor
public class ProductEndpoint {
@Getter(AccessLevel.PROTECTED)
private final ProductService<Product> productSvc;
@FrameworkGetMapping("/{id}") (4)
@Policy(permissionRoots = "PRODUCT") (5)
public Product readProductById(@ContextOperation ContextInfo context, (6) (7)
@PathVariable("id") String productId) {
return productSvc.readByContextId(productId, context);
}
}