修复商品收藏后无法取消,修复取消后无法再次收藏的问题
This commit is contained in:
@ -129,3 +129,8 @@ CREATE TABLE `yx_wechat_live_goods` (
|
|||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信直播商品表' ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信直播商品表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
drop index uid on yx_store_product_relation;
|
@ -236,7 +236,7 @@ public class StoreProductController {
|
|||||||
if(!NumberUtil.isNumber(param.getId())) {
|
if(!NumberUtil.isNumber(param.getId())) {
|
||||||
throw new YshopException("参数非法");
|
throw new YshopException("参数非法");
|
||||||
}
|
}
|
||||||
productRelationService.addRroductRelation(Long.valueOf(param.getId()),uid);
|
productRelationService.addRroductRelation(Long.valueOf(param.getId()),uid,param.getCategory());
|
||||||
return ApiResult.ok();
|
return ApiResult.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public interface YxStoreProductRelationService extends BaseService<YxStoreProduc
|
|||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param uid 用户id
|
* @param uid 用户id
|
||||||
*/
|
*/
|
||||||
void addRroductRelation(long productId,long uid);
|
void addRroductRelation(long productId,long uid,String category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消收藏
|
* 取消收藏
|
||||||
|
@ -78,12 +78,13 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
|
|||||||
* @param uid 用户id
|
* @param uid 用户id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addRroductRelation(long productId,long uid) {
|
public void addRroductRelation(long productId,long uid,String category) {
|
||||||
if(isProductRelation(productId,uid)) {
|
if(isProductRelation(productId,uid)) {
|
||||||
throw new YshopException("已收藏");
|
throw new YshopException("已收藏");
|
||||||
}
|
}
|
||||||
YxStoreProductRelation storeProductRelation = YxStoreProductRelation.builder()
|
YxStoreProductRelation storeProductRelation = YxStoreProductRelation.builder()
|
||||||
.productId(productId)
|
.productId(productId)
|
||||||
|
.category(category)
|
||||||
.uid(uid)
|
.uid(uid)
|
||||||
.type("collect")
|
.type("collect")
|
||||||
.build();
|
.build();
|
||||||
@ -100,7 +101,7 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
|
|||||||
YxStoreProductRelation productRelation = this.lambdaQuery()
|
YxStoreProductRelation productRelation = this.lambdaQuery()
|
||||||
.eq(YxStoreProductRelation::getProductId,productId)
|
.eq(YxStoreProductRelation::getProductId,productId)
|
||||||
.eq(YxStoreProductRelation::getUid,uid)
|
.eq(YxStoreProductRelation::getUid,uid)
|
||||||
.eq(YxStoreProductRelation::getType,category)
|
.eq(YxStoreProductRelation::getCategory,category)
|
||||||
.one();
|
.one();
|
||||||
if(productRelation == null) {
|
if(productRelation == null) {
|
||||||
throw new YshopException("已取消");
|
throw new YshopException("已取消");
|
||||||
|
Reference in New Issue
Block a user