use of com.github.lybgeek.common.elasticsearch.model.EsEntity in project springboot-learning by lyb-geek.
the class AbstractCustomElasticsearchRepository method save.
@Override
public boolean save(T entity) {
String indexName = this.getIndexName();
EsEntity esEntity = this.convertDoToEsEntity(entity);
return elasticsearchHelper.saveOrUpdate(indexName, esEntity);
}
use of com.github.lybgeek.common.elasticsearch.model.EsEntity in project springboot-learning by lyb-geek.
the class ElasticsearchAspect method saveOrUpdate.
private void saveOrUpdate(JoinPoint jp, Object retVal, EsOperate operate) {
String methodName = jp.getSignature().getName();
Object id = elasticsearchHelper.getEsId(retVal);
EsEntity esEntity = new EsEntity();
esEntity.setData(retVal);
if (ObjectUtils.isNotEmpty(id)) {
esEntity.setId(id.toString());
}
boolean isOK = elasticsearchHelper.saveOrUpdate(operate.indexName(), esEntity);
log.info("{} saveOrUpdateToEs success {}", methodName, isOK);
}
use of com.github.lybgeek.common.elasticsearch.model.EsEntity in project springboot-learning by lyb-geek.
the class AbstractCustomElasticsearchRepository method convertDoToEsEntity.
private final EsEntity<T> convertDoToEsEntity(T entity) {
EsEntity esEntity = new EsEntity();
Object id = elasticsearchHelper.getEsId(entity);
if (ObjectUtils.isNotEmpty(id)) {
esEntity.setId(id.toString());
}
esEntity.setData(entity);
return esEntity;
}
use of com.github.lybgeek.common.elasticsearch.model.EsEntity in project springboot-learning by lyb-geek.
the class CustomShortUrlEsServiceImpl method save.
@Override
public String save(ShortUrlDTO shortUrlDTO) {
EsEntity esEntity = EsEntity.builder().id(shortUrlDTO.getId().toString()).data(shortUrlDTO).build();
boolean isOk = elasticsearchHelper.saveOrUpdate(ElasticsearchConstant.SHORT_URL_INDEX, esEntity);
if (isOk) {
return esEntity.getId();
}
return null;
}
use of com.github.lybgeek.common.elasticsearch.model.EsEntity in project springboot-learning by lyb-geek.
the class ElasticsearchEvent method syncShortUrlToEs.
@Async
@EventListener
public void syncShortUrlToEs(ShortUrl shortUrl) {
ShortUrlDTO shortUrlDO = new ShortUrlDTO();
BeanUtils.copyProperties(shortUrl, shortUrlDO);
log.info("syncShortUrlToEs -> {}", shortUrlDO);
EsEntity esEntity = EsEntity.builder().id(shortUrlDO.getId().toString()).data(shortUrlDO).build();
elasticsearchHelper.saveOrUpdate(ElasticsearchConstant.SHORT_URL_INDEX, esEntity);
}
Aggregations