use of com.github.lybgeek.redis.annotation.RedisCache in project springboot-learning by lyb-geek.
the class BookServiceImpl method editBook.
@Override
@Transactional
// @CachePut(cacheNames = "book",key="'edit_'+#id")
@RedisCache(type = CacheOperateType.UPDTAE, cacheKeyPrefix = "editBook", expireTime = 120)
public BookDTO editBook(BookDTO bookDTO) {
Book book = dozerMapper.map(bookDTO, Book.class);
book.setUpdateDate(new Date());
baseMapper.updateById(book);
return getBookById(book.getId());
}
use of com.github.lybgeek.redis.annotation.RedisCache in project springboot-learning by lyb-geek.
the class BookServiceImpl method pageBook.
@Override
@RedisCache(type = CacheOperateType.QUERY, cacheKeyPrefix = "pageBook", expireTime = 180)
public PageResult<BookDTO> pageBook(PageQuery<BookDTO> pageQuery) {
log.info("pageBook走db");
BookDTO bookDTO = pageQuery.getQueryParams();
Wrapper<Book> wrapper = wrapperQueryCondition(bookDTO);
IPage<Book> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<Book> bookIPage = baseMapper.selectPage(page, wrapper);
if (bookIPage != null) {
List<BookDTO> bookDTOS = new ArrayList<>();
if (CollectionUtils.isNotEmpty(bookIPage.getRecords())) {
bookDTOS = BeanMapperUtils.mapList(bookIPage.getRecords(), BookDTO.class);
}
return PageUtil.INSTANCE.getPage(bookIPage, bookDTOS);
}
return null;
}
use of com.github.lybgeek.redis.annotation.RedisCache in project springboot-learning by lyb-geek.
the class BookServiceImpl method getBookByName.
@Override
@RedisCache(type = CacheOperateType.QUERY, expireTime = 180)
public BookDTO getBookByName(String bookName) {
log.info("getBookByName走db");
Wrapper<Book> wrapper = new QueryWrapper<>();
((QueryWrapper<Book>) wrapper).eq("book_name", bookName);
Book book = bookMapper.selectOne(wrapper);
if (ObjectUtils.isNotEmpty(book)) {
return dozerMapper.map(book, BookDTO.class);
}
return null;
}
Aggregations