|
|
@@ -57,14 +57,13 @@ public class NovelServiceImpl implements NovelService {
|
|
|
/**
|
|
|
* 获取小说临时名称
|
|
|
*/
|
|
|
- private String getTemporaryName(String novelName){
|
|
|
+ private String getTemporaryName(String novelName) {
|
|
|
String novelTemporaryName = novelName;
|
|
|
if (StrUtil.isNotEmpty(novelName)) {
|
|
|
if (novelName.length() > 10) {
|
|
|
novelTemporaryName = novelName.substring(0, 6);
|
|
|
- }
|
|
|
- else if (novelName.length() > 2) {
|
|
|
- novelTemporaryName = novelName.substring(0,2) + "**" + novelName.charAt(novelName.length() - 1);
|
|
|
+ } else if (novelName.length() > 2) {
|
|
|
+ novelTemporaryName = novelName.substring(0, 2) + "**" + novelName.charAt(novelName.length() - 1);
|
|
|
}
|
|
|
}
|
|
|
return novelTemporaryName;
|
|
|
@@ -101,6 +100,8 @@ public class NovelServiceImpl implements NovelService {
|
|
|
if (chapter != null) {
|
|
|
YtNovelChapterDto chapterDto = new YtNovelChapterDto();
|
|
|
BeanUtil.copyProperties(chapter, chapterDto);
|
|
|
+ chapterDto.setTotalPage(lastReadRecord.getTotalPage());
|
|
|
+ chapterDto.setReadPage(lastReadRecord.getReadPage());
|
|
|
dto.setLastReadChapter(chapterDto);
|
|
|
}
|
|
|
}
|
|
|
@@ -132,19 +133,37 @@ public class NovelServiceImpl implements NovelService {
|
|
|
if (ytNovelUser == null) {
|
|
|
throw new CustomerException("未知用户");
|
|
|
}
|
|
|
- YtNovelReadRecord readRecord = new YtNovelReadRecord();
|
|
|
- readRecord.setRecordId(IdUtil.fastSimpleUUID());
|
|
|
- readRecord.setUserId(param.getUserId());
|
|
|
- readRecord.setNovelId(param.getNovelId());
|
|
|
- readRecord.setChapterId(param.getChapterId());
|
|
|
- readRecord.setNovelName(param.getNovelName());
|
|
|
- readRecord.setNovelChapterName(param.getChapterName());
|
|
|
- readRecord.setReadTime(new Date());
|
|
|
- readRecord.setCreateTime(new Date());
|
|
|
- readRecord.setUpdateTime(new Date());
|
|
|
- readRecord.setCreateBy(param.getUserId());
|
|
|
- readRecord.setUpdateBy(param.getUserId());
|
|
|
- novelMapper.insertReadRecord(readRecord);
|
|
|
+ // 记录用户阅读章节
|
|
|
+ YtNovelReadRecord readRecord = novelMapper.selectChapterRecord(param);
|
|
|
+ if (readRecord == null) {
|
|
|
+ readRecord = new YtNovelReadRecord();
|
|
|
+ BeanUtil.copyProperties(param, readRecord);
|
|
|
+ readRecord.setRecordId(IdUtil.fastSimpleUUID());
|
|
|
+ readRecord.setReadTime(new Date());
|
|
|
+ readRecord.setCreateTime(new Date());
|
|
|
+ readRecord.setUpdateTime(new Date());
|
|
|
+ readRecord.setCreateBy(param.getUserId());
|
|
|
+ readRecord.setUpdateBy(param.getUserId());
|
|
|
+ if (StrUtil.isEmpty(readRecord.getNovelName())) {
|
|
|
+ YtNovel novel = novelMapper.selectByPrimaryKey(param.getNovelId());
|
|
|
+ readRecord.setNovelName(novel == null ? "" : novel.getNovelName());
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(readRecord.getNovelChapterName())) {
|
|
|
+ YtNovelChapter chapter = novelMapper.selectNovelChapterByPrimaryKey(param.getChapterId());
|
|
|
+ readRecord.setNovelChapterName(chapter == null ? "" : chapter.getChapterName());
|
|
|
+ }
|
|
|
+ novelMapper.insertReadRecord(readRecord);
|
|
|
+ // 更新小说阅读数
|
|
|
+ novelMapper.updateNovelRead(param.getNovelId());
|
|
|
+ }
|
|
|
+ else if (param.getReadPage() == null && param.getTotalPage() != null) {
|
|
|
+ // 已存在章节阅读记录 则更新记录章节页
|
|
|
+ readRecord.setTotalPage(param.getTotalPage());
|
|
|
+ readRecord.setReadPage(param.getReadPage());
|
|
|
+ readRecord.setUpdateTime(new Date());
|
|
|
+ readRecord.setUpdateBy(param.getUserId());
|
|
|
+ novelMapper.updateReadRecord(readRecord);
|
|
|
+ }
|
|
|
return "保存记录成功";
|
|
|
}
|
|
|
|