我使用内容CMA。我有List<String> entriesIds。我想通过它们的I从Contentful空间获取条目,这样我就可以编辑它们并将我的更改发布到Contentful。下面的代码运行得很好,但我只想获取一个请求的条目。
@Setter
@Getter
public class ProductIsAvailableDto {
private String productId;
private Boolean isAvailable;
}
private final CMAClient contentfulClientForUpdate;
for (ProductIsAvailableDto product : productIsAvailableDtoList) {
CMAEntry cmaEntry = contentfulClientForUpdate.entries().fetchOne(product.getProductId());
cmaEntry.setField(ContentfulFieldsConstants.IS_AVAILABLE, DEFAULT_LOCALE, product.getIsAvailable());
cmaEntry = contentfulClientForUpdate.entries().update(cmaEntry);
contentfulClientForUpdate.entries().publish(cmaEntry);
}我面对的方法如下。
com.contentful.java.cma.ModuleEntries#fetchAll(java.util.Map<java.lang.String,java.lang.String>) 但是我真的不能理解如何指定查询参数。我试着像下面这样做smth。
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("ids", new Gson().toJson(productIsAvailableDtoList.stream()
.map(ProductIsAvailableDto::getProductId)
.collect(Collectors.toList())
));
CMAArray<CMAEntry> cmaArray = contentfulClientForUpdate.entries().fetchAll(hashMap);但它不起作用。在官方文档中,我只找到了按id获取单个条目的机会,但我需要按id获取条目列表。如果有人能帮我那就太好了。
发布于 2020-09-29 00:32:34
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put(
"sys.id[in]",
productIsAvailableDtoList.stream()
.map(ProductIsAvailableDto::getProductId)
.collect(Collectors.joining(",")
));
CMAArray<CMAEntry> cmaArray = contentfulClientForUpdate.entries().fetchAll(hashMap);它起作用了),谢谢你的关注。
https://stackoverflow.com/questions/64105625
复制相似问题