完成购物车的修改~

This commit is contained in:
YunaiV
2020-08-15 18:27:55 +08:00
parent 8818b350d6
commit 9fb421360f
13 changed files with 89 additions and 62 deletions

View File

@@ -5,7 +5,7 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;
/**
* 购物车更新是否选中 Request DTO
@@ -23,7 +23,7 @@ public class CartItemUpdateSelectedReqDTO implements Serializable {
* 商品 SKU 编号列表
*/
@NotNull(message = "商品 SKU 编号列表不能为空")
private List<Integer> skuIds;
private Collection<Integer> skuIds;
/**
* 是否选中
*/

View File

@@ -43,7 +43,7 @@ public interface CartItemMapper extends BaseMapper<CartItemDO> {
default List<CartItemDO> selectList(CartItemListQueryBO queryBO) {
return selectList(new QueryWrapperX<CartItemDO>().eq("user_id", queryBO.getUserId())
.eq("selected", queryBO.getSelected()));
.eqIfPresent("selected", queryBO.getSelected()));
}
}

View File

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.mall.orderservice.enums.OrderErrorCodeConstants.CARD_ITEM_NOT_FOUND;
@@ -84,7 +85,7 @@ public class CartService {
* @param skuIds 商品 SKU 编号数组
* @param selected 是否选中
*/
public void updateCartItemSelected(Integer userId, List<Integer> skuIds, Boolean selected) {
public void updateCartItemSelected(Integer userId, Collection<Integer> skuIds, Boolean selected) {
// 查询 CartItemDO 列表
List<CartItemDO> itemDOs = cartItemMapper.selectListByUserIdAndSkuIds(userId, skuIds);
if (skuIds.size() != itemDOs.size()) {