Commit 243f5ac2 authored by fhj's avatar fhj

Merge remote-tracking branch 'origin/v2' into v2

parents dfb105ae 52bf6631
......@@ -5,6 +5,7 @@ import com.ssy.lingxi.common.constant.manage.ShopTypeEnum;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.SimpleIdRequest;
import com.ssy.lingxi.search.entity.CommodityCollectChannel;
import com.ssy.lingxi.search.entity.channelCommodity.ChannelCommodityMember;
import com.ssy.lingxi.search.entity.commodity.Commodity;
......@@ -139,4 +140,16 @@ public class CommodityCollectChannelController extends BaseController {
return Wrapper.success(commodityCollectChannelService.deleteCommodityCollectChannel(sysUser, shopId, commodityCollectChannelRequest));
}
/**
* 删除商品收藏通过id
* @param simpleIdRequest
* @return
*/
@RequestMapping(value = "deleteCommodityCollectById", method = RequestMethod.POST)
public Wrapper<String> deleteCommodityCollectById(@RequestBody SimpleIdRequest simpleIdRequest){
UserLoginCacheDTO sysUser = this.getSysUser();
Long id = simpleIdRequest.getId();
return Wrapper.success(commodityCollectChannelService.deleteCommodityCollectChannelById(sysUser, id));
}
}
......@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.SimpleIdRequest;
import com.ssy.lingxi.search.entity.CommodityCollect;
import com.ssy.lingxi.search.entity.commodity.Commodity;
import com.ssy.lingxi.search.entity.commodity.CommodityShop;
......@@ -104,15 +105,39 @@ public class CommodityCollectController extends BaseController {
}
/**
* 批量新增商品收藏
* @param commodityCollectRequestList 商品收藏实体
* @return
*/
@RequestMapping(value = "/saveCommodityCollectBatch", method = RequestMethod.POST)
public Wrapper<Boolean> saveCommodityCollectBatch(@RequestBody List<CommodityCollectRequest> commodityCollectRequestList){
UserLoginCacheDTO sysUser = this.getSysUser();
Long shopId = Long.parseLong(request.getHeader("shopId"));
return Wrapper.success(commodityCollectService.saveBatchCommodityCollect(sysUser, shopId, commodityCollectRequestList));
}
/**
* 删除商品收藏
* @param commodityCollectRequest
* @return
*/
@RequestMapping(value = "deleteCommodityCollect", method = RequestMethod.POST)
@RequestMapping(value = "/deleteCommodityCollect", method = RequestMethod.POST)
public Wrapper<String> deleteCommodityCollect(@RequestBody CommodityCollectRequest commodityCollectRequest){
UserLoginCacheDTO sysUser = this.getSysUser();
Long shopId = Long.parseLong(request.getHeader("shopId"));
return Wrapper.success(commodityCollectService.deleteCommodityCollect(sysUser, shopId, commodityCollectRequest));
}
/**
* 删除商品收藏通过id
* @param simpleIdRequest 商品收藏id
* @return
*/
@RequestMapping(value = "/deleteCommodityCollectById", method = RequestMethod.POST)
public Wrapper<String> deleteCommodityCollectById(@RequestBody SimpleIdRequest simpleIdRequest){
UserLoginCacheDTO sysUser = this.getSysUser();
Long id = simpleIdRequest.getId();
return Wrapper.success(commodityCollectService.deleteCommodityCollectById(sysUser, id));
}
}
package com.ssy.lingxi.search.model.request;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
/**
* 商城的商品收藏
* @author jw.chen
* @version 2.0.0
* @date 2020/9/25
*/
@Getter
@Setter
public class CommodityCollectBatchRequest implements Serializable {
private static final long serialVersionUID = -7209358219603948888L;
/**
* 商品id
*/
private List<Long> commodityIdList;
}
......@@ -50,4 +50,10 @@ public interface ICommodityCollectChannelService {
*/
String deleteCommodityCollectChannel(UserLoginCacheDTO sysUser, Long shopId, CommodityCollectChannelRequest commodityCollectChannelRequest);
/**
* 删除商品收藏通过id
* @param id
* @return
*/
String deleteCommodityCollectChannelById(UserLoginCacheDTO sysUser, Long id);
}
......@@ -57,4 +57,11 @@ public interface ICommodityCollectService {
*/
String deleteCommodityCollect(UserLoginCacheDTO sysUser, Long shopId, CommodityCollectRequest commodityCollectRequest);
/**
* 删除商品收藏通过id
* @param id
* @return
*/
String deleteCommodityCollectById(UserLoginCacheDTO sysUser, Long id);
}
......@@ -196,5 +196,24 @@ public class CommodityCollectChannelServiceImpl implements ICommodityCollectChan
}
}
/**
* 删除商品收藏通过id
* @param id
* @return
*/
@Override
public String deleteCommodityCollectChannelById(UserLoginCacheDTO sysUser, Long id) {
Long userId = sysUser.getUserId();
CommodityCollectChannel commodityCollectChannel = commodityCollectChannelRepository.findById(id).orElse(null);
if(commodityCollectChannel != null){
Long commodityCollectChannelUserId = commodityCollectChannel.getUserId();
if(commodityCollectChannelUserId.longValue() == userId.longValue()){
commodityCollectChannelRepository.deleteById(id);
return "删除成功";
}
}
throw new BusinessException(ResponseCode.PRODUCT_COMMODITY_COLLECT_NOT_EXIST);
}
}
......@@ -203,5 +203,24 @@ public class CommodityCollectServiceImpl implements ICommodityCollectService {
}
}
/**
* 删除商品收藏通过id
* @param id
* @return
*/
@Override
public String deleteCommodityCollectById(UserLoginCacheDTO sysUser, Long id) {
Long userId = sysUser.getUserId();
CommodityCollect commodityCollect = commodityCollectRepository.findById(id).orElse(null);
if(commodityCollect != null){
Long commodityCollectUserId = commodityCollect.getUserId();
if(commodityCollectUserId.longValue() == userId.longValue()){
commodityCollectRepository.deleteById(id);
return "删除成功";
}
}
throw new BusinessException(ResponseCode.PRODUCT_COMMODITY_COLLECT_NOT_EXIST);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment