Commit d80d8a74 by 朱亚洁

feat:[none]接口优化getBookLabels

parent ffc593a3
......@@ -384,4 +384,10 @@ public class BookConstant {
public static final String BOOK_CITY_MAP = CacheConstant.BOOK + "BOOK_CITY_MAP";
public static final Integer DEFAULT_DAY_TIMEOUT = 24 * 60 * 60;
/**
* 书刊标签缓存
*/
public static final String BOOK_LABEL_CACHE = CacheConstant.BOOK + "BOOK_LABEL";
}
......@@ -104,7 +104,7 @@ public class AnswerSubscribeBizImpl implements AnswerSubscribeBiz {
if (ListUtils.isEmpty(answerList)) {
if ("pro".equals(BookProps.getSystemEnv()) && AppletConstants.NO_ANSWER_BOOK.contains(bookId)) {
hasAnswer = false;
} else {
} else if (!"pro".equals(BookProps.getSystemEnv())){
hasAnswer = false;
}
}
......
......@@ -1967,7 +1967,13 @@ public class BookBizImpl implements BookBiz {
@Override
public Map<Integer, List<BookLabel>> getBookLabels(Long partyId) {
Map<Integer, List<BookLabel>> map = new HashMap<>();
List<BookLabel> bookLabels = bookLabelDao.getAll(partyId);
String key = BookConstant.BOOK_LABEL_CACHE;
List<BookLabel> bookLabels = JedisClusterUtils.hgetJson2List(key, partyId.toString(), BookLabel.class);
if (ListUtils.isEmpty(bookLabels)){
bookLabels = bookLabelDao.getAll(partyId);
JedisClusterUtils.hset2Json(key, partyId.toString(), bookLabels);
JedisClusterUtils.expire(key, 24*3600);
}
if (!ListUtils.isEmpty(bookLabels)) {
map = bookLabels.stream().collect(Collectors.groupingBy(BookLabel::getType));
}
......
......@@ -2,6 +2,7 @@ package com.pcloud.book.book.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookLabelBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.enums.BookLabelAuditState;
......@@ -11,6 +12,7 @@ import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.MapUtils;
......@@ -45,17 +47,15 @@ public class BookLabelBizImpl implements BookLabelBiz {
bookLabel.setAuditState(BookLabelAuditState.pass.code);
bookLabel.setSeq(seq+1);
bookLabelDao.insert(bookLabel);
return;
}
if (SystemCode.adviser.code.equalsIgnoreCase(systemCode)){//编辑端要审核
} else if (SystemCode.adviser.code.equalsIgnoreCase(systemCode)){//编辑端要审核
if (StringUtil.isEmpty(bookLabel.getRemark())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少标签申请说明");
}
bookLabel.setAuditState(BookLabelAuditState.wait.code);
bookLabel.setSeq(seq+1);
bookLabelDao.insert(bookLabel);
return;
}
JedisClusterUtils.del(BookConstant.BOOK_LABEL_CACHE);
}
@Override
......@@ -82,11 +82,13 @@ public class BookLabelBizImpl implements BookLabelBiz {
updateLabel.setUpdateLabelId(labelId);
}
bookLabelDao.update(updateLabel);
JedisClusterUtils.del(BookConstant.BOOK_LABEL_CACHE);
}
@Override
public void deleteById(Long labelId) {
bookLabelDao.deleteById(labelId);
JedisClusterUtils.del(BookConstant.BOOK_LABEL_CACHE);
}
@Override
......@@ -95,6 +97,7 @@ public class BookLabelBizImpl implements BookLabelBiz {
updateLabel.setId(labelId);
updateLabel.setSeq(seq);
bookLabelDao.update(updateLabel);
JedisClusterUtils.del(BookConstant.BOOK_LABEL_CACHE);
}
@Override
......
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