【问题标题】:Custom CustomerEndPoint Broadleaf自定义 CustomerEndPoint 阔叶
【发布时间】:2014-07-10 18:37:40
【问题描述】:

我是阔叶新手。我想创建一个自定义 customerEndPoint 类,它将提供诸如注册客户获取客户详细信息等服务。我尝试在 com.mycompany.api.endpoint.customer 包中创建一个 CustomerEndpoint 类。是否有任何其他配置可以访问客户 url??

请帮忙...

【问题讨论】:

    标签: api rest broadleaf-commerce


    【解决方案1】:

    我解决了这个问题,分享它,因为它可能对某人有帮助。 我在 applicationContent-rest-api.xml 中配置了 CustomerEndPoint bean,并将 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"/>
    

    【讨论】:

      【解决方案2】:

      这取决于您使用的任何版本。如果您使用例如:broadleaf-3.1.X 请参阅 http://mvnrepository.com/artifact/org.broadleafcommerce/broadleaf-framework/3.1.5-GA

      你可以以com.mycompany.api.endpoint.checkout.CheckoutEndpoint为例。

      进入默认平台有org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint,但这个实现是空的。

      您可以扩展该类并添加类似于com.mycompany.api.endpoint.checkout.CheckoutEndpoint 的注释,也可以根据您的需要添加业务逻辑。

      据我所知,平台中没有一些平台默认实现 int broadleaf-3.1.6-GA

      【讨论】:

      • 感谢您的意见。我扩展了 BaseEndpoint 类并忽略了 org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint 因为它没有提供任何东西。
      • 很高兴我的回答对您有所帮助。将来您可以以另一个类似的类为例,并使用您的具体实现
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-20
      • 2018-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多