package com.bawei.mall.car.controller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.car.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Array;
import java.util.List;


/**
 * 购物车控制层
 *
 * @program: mall_cloud
 * @ClassName: CarController
 * @author: Gyc
 * @create: 2024-05-06 16:02
 **/
@RestController
public class CarController {
    @Autowired
    private CarService carService;

    @PostMapping("/addCar")
    public R addCar(@RequestParam Integer skuId,@RequestParam Integer status){
        carService.addCar(skuId, status);
        return R.ok();
    }

    @PostMapping("/updCar")
    public R updCar(@RequestParam Integer skuId, @RequestParam Integer num){
        carService.updCar(skuId, num);
        return R.ok();
    }

    @PostMapping("/cleanCar")
    public R delCar(){
        carService.delCar();
        return R.ok();
    }

    @PostMapping("/delById")
    public R delById(@RequestParam("skuIds") String skuIds){
        carService.delById(skuIds);
        return R.ok();
    }

    //查询接口
    @PostMapping("/calculate")
    public R calculate(){
        return R.ok(carService.calculate());
    }



}
