修复商品收藏后无法取消,修复取消后无法再次收藏的问题

This commit is contained in:
LIONCITYS\lioncity
2020-11-06 17:41:44 +08:00
parent 48ea2c8d60
commit 346f725758
4 changed files with 10 additions and 4 deletions

View File

@ -43,7 +43,7 @@ public interface YxStoreProductRelationService extends BaseService<YxStoreProduc
* @param productId 商品id
* @param uid 用户id
*/
void addRroductRelation(long productId,long uid);
void addRroductRelation(long productId,long uid,String category);
/**
* 取消收藏

View File

@ -78,12 +78,13 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
* @param uid 用户id
*/
@Override
public void addRroductRelation(long productId,long uid) {
public void addRroductRelation(long productId,long uid,String category) {
if(isProductRelation(productId,uid)) {
throw new YshopException("已收藏");
}
YxStoreProductRelation storeProductRelation = YxStoreProductRelation.builder()
.productId(productId)
.category(category)
.uid(uid)
.type("collect")
.build();
@ -100,7 +101,7 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
YxStoreProductRelation productRelation = this.lambdaQuery()
.eq(YxStoreProductRelation::getProductId,productId)
.eq(YxStoreProductRelation::getUid,uid)
.eq(YxStoreProductRelation::getType,category)
.eq(YxStoreProductRelation::getCategory,category)
.one();
if(productRelation == null) {
throw new YshopException("已取消");