商品:用户未登录时,不记录商品浏览记录

This commit is contained in:
owen 2023-12-19 21:44:04 +08:00
parent 9c341be4ae
commit 0944584029
1 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,11 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
@Override
public Long createBrowseHistory(Long userId, Long spuId) {
// 用户未登录时不记录
if (userId == null) {
return null;
}
// 情况一同一个商品只保留最新的一条记录
ProductBrowseHistoryDO historyDO = browseHistoryMapper.selectOne(ProductBrowseHistoryDO::getUserId, userId, ProductBrowseHistoryDO::getSpuId, spuId);
if (historyDO != null) {