我关注了博客,并且能够在自定义OData服务上执行创建,读取和更新操作,但是我找不到用于删除操作的任何博客/文档。 请帮忙。
答案 0 :(得分:7)
没有专门的博客文章来对自定义OData服务执行删除操作,但我们建议您遵循以下模式:
public class DeleteAddressCommand extends ErpCommand<Integer> {
private static final Logger logger = CloudLoggerFactory.getLogger(DeleteAddressCommand.class);
private final BusinessPartnerService service;
private final String businessPartnerId;
private final String addressId;
public DeleteAddressCommand(final BusinessPartnerService service,
final String businessPartnerId, final String addressId) {
super(HystrixUtil.getDefaultErpCommandSetter(
DeleteAddressCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));
this.service = service;
this.businessPartnerId = businessPartnerId;
this.addressId = addressId;
}
@Override
protected Integer run() throws Exception {
final BusinessPartnerAddress addressToDelete = BusinessPartnerAddress.builder()
.businessPartner(businessPartnerId)
.addressID(addressId)
.build();
final ODataDeleteResult oDataDeleteResult = service
.deleteBusinessPartnerAddress(addressToDelete)
.execute();
return oDataDeleteResult.getHttpStatusCode();
}
}
我从this official example粘贴了代码
最良好的祝愿 弗洛里安