Search in sources :

Example 11 with ShortUrlDTO

use of com.github.lybgeek.shorturl.dto.ShortUrlDTO in project springboot-learning by lyb-geek.

the class ElasticsearchApplicationTest method testSaveAndReturnShortUrl.

@Test
public void testSaveAndReturnShortUrl() {
    ShortUrlDTO shortUrlDTO = ShortUrlDTO.builder().longUrl("https://www.baidu.com").urlName("百度").remark("百度一下,你就知道").build();
    String shortUrl = shortUrlService.saveAndReturnShortUrl(shortUrlDTO);
    Assert.assertNotNull(shortUrl);
    System.out.println(shortUrl);
}
Also used : ShortUrlDTO(com.github.lybgeek.shorturl.dto.ShortUrlDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ShortUrlDTO

use of com.github.lybgeek.shorturl.dto.ShortUrlDTO 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);
}
Also used : EsEntity(com.github.lybgeek.common.elasticsearch.model.EsEntity) ShortUrlDTO(com.github.lybgeek.shorturl.dto.ShortUrlDTO) Async(org.springframework.scheduling.annotation.Async) EventListener(org.springframework.context.event.EventListener)

Example 13 with ShortUrlDTO

use of com.github.lybgeek.shorturl.dto.ShortUrlDTO in project springboot-learning by lyb-geek.

the class ElasticsearchApplicationTest method testUpdateShortUrl.

@Test
public void testUpdateShortUrl() {
    ShortUrlDTO shortUrlDTO = ShortUrlDTO.builder().id(1L).longUrl("https://www.baidu.com").urlName("百度").remark("百度搜索引擎").build();
    ShortUrlDTO shortUrl = shortUrlService.saveShortUrl(shortUrlDTO);
    Assert.assertNotNull(shortUrl);
    System.out.println(shortUrl);
}
Also used : ShortUrlDTO(com.github.lybgeek.shorturl.dto.ShortUrlDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with ShortUrlDTO

use of com.github.lybgeek.shorturl.dto.ShortUrlDTO in project springboot-learning by lyb-geek.

the class ElasticsearchApplicationTest method testSaveShortUrl.

@Test
public void testSaveShortUrl() {
    ShortUrlDTO shortUrlDTO = ShortUrlDTO.builder().longUrl("https://music.wangyiyun.com").urlName("网易云").remark("网易云音乐").build();
    ShortUrlDTO shortUrl = shortUrlService.saveShortUrl(shortUrlDTO);
    Assert.assertNotNull(shortUrl);
    System.out.println(shortUrl);
}
Also used : ShortUrlDTO(com.github.lybgeek.shorturl.dto.ShortUrlDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ShortUrlDTO (com.github.lybgeek.shorturl.dto.ShortUrlDTO)14 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 PageQuery (com.github.lybgeek.common.model.PageQuery)2 ShortUrlVO (com.github.lybgeek.elasticsearch.model.ShortUrlVO)2 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)2 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)2 EsEntity (com.github.lybgeek.common.elasticsearch.model.EsEntity)1 SearchSourceBuilder (org.elasticsearch.search.builder.SearchSourceBuilder)1 HighlightBuilder (org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder)1 EventListener (org.springframework.context.event.EventListener)1 Pageable (org.springframework.data.domain.Pageable)1 Sort (org.springframework.data.domain.Sort)1 NativeSearchQueryBuilder (org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder)1 Async (org.springframework.scheduling.annotation.Async)1