【功能优化】全局:增加 selectFirstOne 方法,解决容易出现并发场景下的查询

This commit is contained in:
YunaiV
2025-03-16 16:31:36 +08:00
parent 36165e72fc
commit 2dc8071faa
3 changed files with 35 additions and 13 deletions

View File

@@ -21,9 +21,8 @@ import java.util.Collection;
public interface ProductBrowseHistoryMapper extends BaseMapperX<ProductBrowseHistoryDO> {
default ProductBrowseHistoryDO selectByUserIdAndSpuId(Long userId, Long spuId) {
return selectOne(new LambdaQueryWrapperX<ProductBrowseHistoryDO>()
.eq(ProductBrowseHistoryDO::getUserId, userId)
.eq(ProductBrowseHistoryDO::getSpuId, spuId));
return selectFirstOne(ProductBrowseHistoryDO::getUserId, userId,
ProductBrowseHistoryDO::getSpuId, spuId);
}
default PageResult<ProductBrowseHistoryDO> selectPage(ProductBrowseHistoryPageReqVO reqVO) {