|
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.product.service.favorite;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO;
|
|
|
-import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO;
|
|
|
import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert;
|
|
|
import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO;
|
|
|
import cn.iocoder.yudao.module.product.dal.mysql.favorite.ProductFavoriteMapper;
|
|
@@ -30,22 +29,20 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
|
|
private ProductFavoriteMapper productFavoriteMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Long createFavorite(Long userId, @Valid AppFavoriteReqVO reqVO) {
|
|
|
- ProductFavoriteDO favorite = productFavoriteMapper.selectByUserAndSpuAndType(
|
|
|
- userId, reqVO.getSpuId(), reqVO.getType());
|
|
|
+ public Long createFavorite(Long userId, Long spuId) {
|
|
|
+ ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
|
|
if (Objects.nonNull(favorite)) {
|
|
|
throw exception(FAVORITE_EXISTS);
|
|
|
}
|
|
|
|
|
|
- ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, reqVO);
|
|
|
+ ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, spuId);
|
|
|
productFavoriteMapper.insert(entity);
|
|
|
return entity.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteFavorite(Long userId, @Valid AppFavoriteReqVO reqVO) {
|
|
|
- ProductFavoriteDO favorite = productFavoriteMapper.selectByUserAndSpuAndType(
|
|
|
- userId, reqVO.getSpuId(), reqVO.getType());
|
|
|
+ public void deleteFavorite(Long userId, Long spuId) {
|
|
|
+ ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
|
|
if (Objects.isNull(favorite)) {
|
|
|
throw exception(FAVORITE_NOT_EXISTS);
|
|
|
}
|
|
@@ -55,12 +52,12 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
|
|
|
|
|
@Override
|
|
|
public PageResult<ProductFavoriteDO> getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO) {
|
|
|
- return productFavoriteMapper.selectPageByUserAndType(userId, reqVO.getType(), reqVO);
|
|
|
+ return productFavoriteMapper.selectPageByUserAndType(userId, reqVO);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ProductFavoriteDO getFavorite(Long userId, @Valid AppFavoriteReqVO reqVO) {
|
|
|
- return productFavoriteMapper.selectByUserAndSpuAndType(userId, reqVO.getSpuId(), reqVO.getType());
|
|
|
+ public ProductFavoriteDO getFavorite(Long userId, Long spuId) {
|
|
|
+ return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
|
|
}
|
|
|
|
|
|
}
|