use of com.example.esdemo.dto.Commodity in project demo by breeze0630.
the class CjsElasticsearchExampleApplicationTests method testInsert.
@Test
public void testInsert() {
Commodity commodity = new Commodity();
commodity.setSkuId("1501009001");
commodity.setName("原味切片面包(10片装)");
commodity.setCategory("101");
commodity.setPrice(880);
commodity.setBrand("良品铺子");
commodity.setStock(1);
commodityService.save(commodity);
commodity = new Commodity();
commodity.setSkuId("1501009002");
commodity.setName("原味切片面包(6片装)");
commodity.setCategory("101");
commodity.setPrice(680);
commodity.setBrand("良品铺子");
commodity.setStock(2);
commodityService.save(commodity);
commodity = new Commodity();
commodity.setSkuId("1501009004");
commodity.setName("元气吐司850g");
commodity.setCategory("101");
commodity.setPrice(120);
commodity.setBrand("百草味");
commodity.setStock(3);
commodityService.save(commodity);
}
use of com.example.esdemo.dto.Commodity in project demo by breeze0630.
the class CjsElasticsearchExampleApplicationTests method testDelete.
@Test
public void testDelete() {
Commodity commodity = new Commodity();
commodity.setSkuId("1501009002");
commodityService.delete(commodity);
}
use of com.example.esdemo.dto.Commodity in project demo by breeze0630.
the class CjsElasticsearchExampleApplicationTests method testDeleteAll.
@Test
public void testDeleteAll() {
Iterable<Commodity> iterable = commodityService.getAll();
for (Commodity commodity : iterable) {
commodityService.delete(commodity);
}
Iterable<Commodity> iterable2 = commodityService.getAll();
if (iterable2 == null) {
System.out.println("success");
}
}
use of com.example.esdemo.dto.Commodity in project demo by breeze0630.
the class ElasticsearchTemplateTest method testQuery.
@Test
public void testQuery() {
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(QueryBuilders.matchQuery("name", "吐司")).build();
List<Commodity> list = elasticsearchTemplate.queryForList(searchQuery, Commodity.class);
System.out.println(list);
}
use of com.example.esdemo.dto.Commodity in project demo by breeze0630.
the class CommodityServiceImpl method getByName.
@Override
public List<Commodity> getByName(String name) {
List<Commodity> list = new ArrayList<>();
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("name", name);
Iterable<Commodity> iterable = commodityRepository.search(matchQueryBuilder);
iterable.forEach(e -> list.add(e));
return list;
}
Aggregations