|
|
@@ -92,19 +92,21 @@ public class NovelServiceImpl implements NovelService {
|
|
|
BeanUtil.copyProperties(novel, dto);
|
|
|
dto.setNovelTemporaryName(getTemporaryName(dto.getNovelName()));
|
|
|
// 查询最后阅读章节
|
|
|
+ YtNovelReadRecord lastReadRecord = null;
|
|
|
+ YtNovelChapter chapter = null;
|
|
|
if (StrUtil.isNotEmpty(userId)) {
|
|
|
- YtNovelReadRecord lastReadRecord = novelMapper.selectLastRecord(userId, novelId);
|
|
|
- if (lastReadRecord != null && StrUtil.isNotEmpty(lastReadRecord.getChapterId())) {
|
|
|
- dto.setLastReadChapterId(lastReadRecord.getChapterId());
|
|
|
- YtNovelChapter chapter = novelMapper.selectNovelChapterByPrimaryKey(lastReadRecord.getChapterId());
|
|
|
- if (chapter != null) {
|
|
|
- YtNovelChapterDto chapterDto = new YtNovelChapterDto();
|
|
|
- BeanUtil.copyProperties(chapter, chapterDto);
|
|
|
- chapterDto.setTotalPage(lastReadRecord.getTotalPage());
|
|
|
- chapterDto.setReadPage(lastReadRecord.getReadPage());
|
|
|
- dto.setLastReadChapter(chapterDto);
|
|
|
- }
|
|
|
- }
|
|
|
+ lastReadRecord = novelMapper.selectLastRecord(userId, novelId);
|
|
|
+ }
|
|
|
+ if (lastReadRecord != null && StrUtil.isNotEmpty(lastReadRecord.getChapterId())) {
|
|
|
+ dto.setLastReadChapterId(lastReadRecord.getChapterId());
|
|
|
+ chapter = novelMapper.selectNovelChapterByPrimaryKey(lastReadRecord.getChapterId());
|
|
|
+ }
|
|
|
+ if (chapter != null) {
|
|
|
+ YtNovelChapterDto chapterDto = new YtNovelChapterDto();
|
|
|
+ BeanUtil.copyProperties(chapter, chapterDto);
|
|
|
+ chapterDto.setTotalPage(lastReadRecord.getTotalPage());
|
|
|
+ chapterDto.setReadPage(lastReadRecord.getReadPage());
|
|
|
+ dto.setLastReadChapter(chapterDto);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
|
@@ -156,7 +158,7 @@ public class NovelServiceImpl implements NovelService {
|
|
|
// 更新小说阅读数
|
|
|
novelMapper.updateNovelRead(param.getNovelId());
|
|
|
}
|
|
|
- else if (param.getReadPage() == null && param.getTotalPage() != null) {
|
|
|
+ else if (param.getReadPage() != null && param.getTotalPage() != null) {
|
|
|
// 已存在章节阅读记录 则更新记录章节页
|
|
|
readRecord.setTotalPage(param.getTotalPage());
|
|
|
readRecord.setReadPage(param.getReadPage());
|