Api 自定义点阔叶
我是新来的阔叶树。我想创建一个自定义customerEndPoint类,该类将提供注册客户、获取客户详细信息等服务。我尝试在com.mycompany.api.endpoint.customer包中创建一个customerEndPoint类。是否需要进行其他配置来访问客户URLApi 自定义点阔叶,api,rest,broadleaf-commerce,Api,Rest,Broadleaf Commerce,我是新来的阔叶树。我想创建一个自定义customerEndPoint类,该类将提供注册客户、获取客户详细信息等服务。我尝试在com.mycompany.api.endpoint.customer包中创建一个customerEndPoint类。是否需要进行其他配置来访问客户URL 请对此提供帮助…这取决于您使用的版本。如果使用例如:broadleaf-3.1.X,请参见 您可以以com.mycompany.api.endpoint.checkout.CheckoutEndpoint为例 默认平台
请对此提供帮助…这取决于您使用的版本。如果使用例如:broadleaf-3.1.X,请参见 您可以以
com.mycompany.api.endpoint.checkout.CheckoutEndpoint
为例
默认平台中有org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint
,但此实现是空的
您可以扩展该类并添加类似于com.mycompany.api.endpoint.checkout.CheckoutEndpoint的注释,还可以根据需要添加业务逻辑
据我所知,在broadleaf-3.1.6-GA中没有任何平台默认实现。我解决了这个问题,并将其共享,因为这可能对某些人有所帮助。
我在applicationContent-rest-api.xml中配置了CustomerEndpointbean,并将CustomerEndPoint注释为控制器,只是扩展了BaseEndPoint
CustomerEndpoint.java
@Controller
@Scope("singleton")
@Path("/customer/")
@Produces(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class CustomerEndpoint extends BaseEndpoint {
@Resource(name = "blCustomerService")
protected CustomerService customerService;
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
@GET
public CustomerWrapper getCustomer(@Context HttpServletRequest request,
@QueryParam("id") String emailId) {
CustomerWrapper customerWrapper = new CustomerWrapper();
if (emailId != null && emailId != "") {
customerWrapper.wrapDetails(
customerService.readCustomerByEmail(emailId), request);
}
return customerWrapper;
}
}
applicationContext-rest-api.xml
<bean id="customerEndpoint" class="com.mycompany.api.endpoint.customer.CustomerEndpoint"/>
感谢您的输入。我扩展了BaseEndpoint类,并忽略了org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint,因为它不提供任何内容。我很高兴我的回答对您有所帮助。将来,您可以以另一个类似的类为例,使用特定的实现