use of com.github.lybgeek.common.model.PageQuery in project springboot-learning by lyb-geek.
the class ElasticsearchAspect method around.
@Around(value = "@annotation(operate)")
public Object around(ProceedingJoinPoint pjp, EsOperate operate) {
OperateType type = operate.type();
Object[] args = pjp.getArgs();
Object result = null;
String methodName = pjp.getSignature().getName();
if (ArrayUtils.isNotEmpty(args) && args.length == 1) {
Object param = args[0];
switch(type) {
case QUERY:
if (param instanceof PageQuery) {
PageQuery pageQuery = (PageQuery) param;
result = this.pageQuery(pageQuery, operate.indexName());
} else {
result = this.query(param, operate.indexName());
}
break;
}
}
if (ObjectUtils.isEmpty(result)) {
try {
log.info("{} load data from db", methodName);
return pjp.proceed();
} catch (Throwable throwable) {
log.error(throwable.getMessage(), throwable);
}
}
if (OperateType.QUERY == type) {
log.info("{} load data from es", methodName);
}
return result;
}
use of com.github.lybgeek.common.model.PageQuery in project springboot-learning by lyb-geek.
the class ShortUrlServiceImpl method getShortUrlPageQuery.
private PageQuery<ShortUrl> getShortUrlPageQuery(PageQuery<ShortUrlDTO> pageQuery) {
PageQuery<ShortUrl> query = new PageQuery<>();
BeanUtils.copyProperties(pageQuery, query);
ShortUrl shortUrl = BeanMapperUtil.map(pageQuery.getQueryParams(), ShortUrl.class);
query.setQueryParams(shortUrl);
return query;
}
use of com.github.lybgeek.common.model.PageQuery in project springboot-learning by lyb-geek.
the class ElasticsearchApplicationTest method testPage.
@Test
public void testPage() {
PageQuery pageQuery = new PageQuery<>().setPageNo(1).setPageSize(5);
ShortUrlDTO dto = new ShortUrlDTO();
dto.setUrlName("门户");
// dto.setRemark("门户");
pageQuery.setQueryParams(dto);
PageResult<ShortUrlDTO> pageResult = shortUrlService.pageShortUrl(pageQuery);
System.out.println(pageResult);
}
use of com.github.lybgeek.common.model.PageQuery in project springboot-learning by lyb-geek.
the class ElasticsearchApplicationTest method testCustomPageShortUrl.
@Test
public void testCustomPageShortUrl() {
PageQuery pageQuery = new PageQuery<>().setPageNo(5).setPageSize(5);
ShortUrlDTO dto = new ShortUrlDTO();
// dto.setUrlName("优酷");
// dto.setRemark("视频");
// pageQuery.setQueryParams(dto);
PageResult<ShortUrlDTO> pageResult = customShortUrlEsService.pageShortUrl(pageQuery);
System.out.println(pageResult);
}
use of com.github.lybgeek.common.model.PageQuery in project springboot-learning by lyb-geek.
the class RedisApplicationTest method testPageBook.
@Test
public void testPageBook() {
PageQuery pageQuery = new PageQuery<>().setPageNo(1).setPageSize(5);
BookDTO bookDTO = new BookDTO();
bookDTO.setAuthor("张三");
// bookDTO.setBookName("图解Http");
// bookDTO.setId(4L);
pageQuery.setQueryParams(bookDTO);
PageResult<BookDTO> pageResult = bookService.pageBook(pageQuery);
if (pageResult != null) {
pageResult.getList().forEach(book -> System.out.println(book));
}
}
Aggregations