content: package io.github.xxyopen.novel.book.manager.cache;
  
  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  import io.github.xxyopen.novel.book.dao.entity.BookContent;
  import io.github.xxyopen.novel.book.dao.mapper.BookContentMapper;
  import io.github.xxyopen.novel.common.constant.CacheConsts;
  import io.github.xxyopen.novel.common.constant.DatabaseConsts;
  import lombok.RequiredArgsConstructor;
  import org.springframework.cache.annotation.Cacheable;
  import org.springframework.stereotype.Component;
  
  /**
   * 小说内容 缓存管理类
   *
   * @author xiongxiaoyang
   * @date 2022/5/12
   */
  @Component
  @RequiredArgsConstructor
  public class BookContentCacheManager {
  
      private final BookContentMapper bookContentMapper;
  
      /**
       * 查询小说内容，并放入缓存中
       */
      @Cacheable(cacheManager = CacheConsts.REDIS_CACHE_MANAGER,
          value = CacheConsts.BOOK_CONTENT_CACHE_NAME)
      public String getBookContent(Long chapterId) {
          QueryWrapper<BookContent> contentQueryWrapper = new QueryWrapper<>();
          contentQueryWrapper.eq(DatabaseConsts.BookContentTable.COLUMN_CHAPTER_ID, chapterId)
              .last(DatabaseConsts.SqlEnum.LIMIT_1.getSql());
          BookContent bookContent = bookContentMapper.selectOne(contentQueryWrapper);
          return bookContent.getContent();
      }
  
  
  }
  