|
@@ -1,9 +1,20 @@
|
|
|
package com.sf.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.sf.dto.resp.BookChapterRespDto;
|
|
|
+import com.sf.dto.resp.BookContentAboutRespDto;
|
|
|
+import com.sf.dto.resp.BookInfoRespDto;
|
|
|
+import com.sf.entity.BookChapter;
|
|
|
import com.sf.entity.BookContent;
|
|
|
+import com.sf.entity.BookInfo;
|
|
|
+import com.sf.mapper.BookChapterMapper;
|
|
|
import com.sf.mapper.BookContentMapper;
|
|
|
+import com.sf.mapper.BookInfoMapper;
|
|
|
import com.sf.service.IBookContentService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -17,4 +28,67 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class BookContentServiceImpl extends ServiceImpl<BookContentMapper, BookContent> implements IBookContentService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BookInfoMapper bookInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BookChapterMapper bookChapterMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BookContentMapper bookContentMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BookContentAboutRespDto getBookContentAbout(Long chapterId) {
|
|
|
+ // 查询章节信息
|
|
|
+ // select * from book_chapter where id = 'chapterId';
|
|
|
+ BookChapter bookChapter = bookChapterMapper.selectById(chapterId);
|
|
|
+ BookChapterRespDto bookChapterDto = BookChapterRespDto.builder()
|
|
|
+ .id(chapterId)
|
|
|
+ .bookId(bookChapter.getBookId())
|
|
|
+ .chapterNum(bookChapter.getChapterNum().intValue())
|
|
|
+ .chapterName(bookChapter.getChapterName())
|
|
|
+ .chapterWordCount(bookChapter.getWordCount())
|
|
|
+ .chapterUpdateTime(bookChapter.getUpdateTime())
|
|
|
+ .isVip(bookChapter.getIsVip().intValue())
|
|
|
+ .build();
|
|
|
+// BeanUtils.copyProperties(bookChapter, bookChapterDto);
|
|
|
+
|
|
|
+ // 查询章节内容
|
|
|
+ // select * from book_content where chapter_id = 'chapterId' limit 1;
|
|
|
+ LambdaQueryWrapper<BookContent> contentQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ contentQueryWrapper.eq(BookContent::getChapterId, chapterId).last("LIMIT 1");
|
|
|
+ // selectOne 查询一条数据 selectList 查询多条数据
|
|
|
+ BookContent bookContent = bookContentMapper.selectOne(contentQueryWrapper);
|
|
|
+ String content = bookContent.getContent();
|
|
|
+
|
|
|
+ // 查询小说信息
|
|
|
+ // select * from book_info where id = 'bookId';
|
|
|
+ Long id = bookChapter.getBookId();
|
|
|
+ BookInfo bookInfo = bookInfoMapper.selectById(id);
|
|
|
+ BookInfoRespDto bookInfoDto = BookInfoRespDto.builder().build();
|
|
|
+ // 组装响应对象
|
|
|
+ BeanUtils.copyProperties(bookInfo, bookInfoDto);
|
|
|
+// BookInfoRespDto bookInfoDto1 = BookInfoRespDto.builder()
|
|
|
+// .id(bookInfo.getId())
|
|
|
+// .bookName(bookInfo.getBookName())
|
|
|
+// .bookDesc(bookInfo.getBookDesc())
|
|
|
+// .bookStatus(bookInfo.getBookStatus().intValue())
|
|
|
+// .authorId(bookInfo.getAuthorId())
|
|
|
+// .authorName(bookInfo.getAuthorName())
|
|
|
+// .categoryId(bookInfo.getCategoryId())
|
|
|
+// .categoryName(bookInfo.getCategoryName())
|
|
|
+// .commentCount(bookInfo.getCommentCount())
|
|
|
+// .lastChapterId(bookInfo.getLastChapterId())
|
|
|
+// .picUrl(bookInfo.getPicUrl())
|
|
|
+// .visitCount(bookInfo.getVisitCount())
|
|
|
+// .wordCount(bookInfo.getWordCount())
|
|
|
+// .build();
|
|
|
+
|
|
|
+ // 组装数据并返回
|
|
|
+ return BookContentAboutRespDto.builder()
|
|
|
+ .bookInfo(bookInfoDto)
|
|
|
+ .chapterInfo(bookChapterDto)
|
|
|
+ .bookContent(content)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
}
|