Commit 99c6be73 by 田超

Merge branch 'fixbug/getBookById' into 'master'

bug: [none] 接口优化  fixbug/getBookById

See merge request rays/pcloud-book!1510
parents 72213187 c414f2c5
......@@ -113,6 +113,7 @@ import com.pcloud.book.book.vo.request.BookQualifyInfoVO;
import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.book.vo.request.SyncRelateDataToRaysVO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto;
import com.pcloud.book.constant.CacheConstants;
import com.pcloud.book.consumer.analysisengine.SceneRecordConsr;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.app.AssistTempletConsr;
......@@ -490,6 +491,9 @@ public class BookBizImpl implements BookBiz {
BookDto bookDto = this.getBaseById(book.getBookId());
checkIsUpdateCoverImgAndSendTopic(bookDto, book.getCoverImg());
checkIsUpdateBookNameAndSendTopic(bookDto, book.getBookName());
String cacheKey = CacheConstants.BOOK_TEMPLET_CACHE + CacheConstants.SEPARATOR + bookDto.getAdviserId() +
CacheConstants.SEPARATOR + bookDto.getChannelId() + CacheConstants.SEPARATOR + bookDto.getBookId();
JedisClusterUtils.del(cacheKey);
bookDao.update(book);
//修改版次信息
insertEdition(book.getLastModifiedUser(),book.getEdition(),book.getBookId());
......@@ -556,6 +560,9 @@ public class BookBizImpl implements BookBiz {
if (BookConstant.DEFAULT_BOOK_ISBN.equals(book.getIsbn()) && StringUtils.isEmpty(book.getSerialNumber())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "默认图书不能修改!");
}
String cacheKey = CacheConstants.BOOK_TEMPLET_CACHE + CacheConstants.SEPARATOR + book.getCreatedUser() +
CacheConstants.SEPARATOR + book.getChannelId() + CacheConstants.SEPARATOR + book.getBookId();
JedisClusterUtils.del(cacheKey);
// 修改书籍
bookDao.update(book);
esBookAndAdviserBiz.updateBookAndAdviserToES(Collections.singletonList(book.getBookId()));
......@@ -1744,11 +1751,20 @@ public class BookBizImpl implements BookBiz {
"获取图书基本信息(编辑 - 运营 - 图书)<START>adviserId=" + adviserId + "channelId=" + channelId + "bookId=" + bookId);
BookDto bookDto = this.getBaseById(bookId);
if (bookDto != null) {
String cacheKey = CacheConstants.BOOK_TEMPLET_CACHE + CacheConstants.SEPARATOR + adviserId +
CacheConstants.SEPARATOR + channelId + CacheConstants.SEPARATOR + bookId;
BookDto cacheBookDto = JedisClusterUtils.getJson(cacheKey, BookDto.class);
if (Objects.nonNull(cacheBookDto)) {
bookDto.setTempletId(cacheBookDto.getTempletId());
bookDto.setTempletName(cacheBookDto.getTempletName());
cacheBookDto.setQrRemark(cacheBookDto.getQrRemark());
} else {
// 获取图书类型
Long templetId = bookDao.getTempletId(adviserId, channelId, bookId);
bookDto.setTempletId(templetId);
bookDto.setTempletId(bookDao.getTempletId(adviserId, channelId, bookId));
// 设置图书类型名称
bookSet.setTemplateName(bookDto);
JedisClusterUtils.setJson(cacheKey, bookDto, Math.toIntExact(TimeUnit.HOURS.toSeconds(2)));
}
}
return bookDto;
}
......
package com.pcloud.book.constant;
public class CacheConstants {
private static final String APP_NAME = "BOOK";
public static final String SEPARATOR = "::";
public static final String BOOK_TEMPLET_CACHE = APP_NAME + SEPARATOR + "BOOK_TEMPLET_CACHE" + SEPARATOR;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment