package com.m2pool.lease.controller;


import com.m2pool.lease.annotation.LoginRequired;
import com.m2pool.lease.dto.PageResult;
import com.m2pool.lease.dto.Result;
import com.m2pool.lease.dto.ShopCartDto;
import com.m2pool.lease.dto.v2.ShopCartV2Dto;
import com.m2pool.lease.service.LeaseShoppingCartService;
import com.m2pool.lease.vo.BaseVo;
import com.m2pool.lease.vo.PageVo;
import com.m2pool.lease.vo.ProductAndMachineVo;
import com.m2pool.lease.vo.ShoppingCartInfoURDVo;
import com.m2pool.lease.vo.v2.AddGoodsVo;
import com.m2pool.lease.vo.v2.CartInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 购物车表 前端控制器
 * </p>
 *
 * @author yyb
 * @since 2025-07-23
 */
@Api(tags = "v2版本---购物车表控制器")
@LoginRequired
@RestController
@RequestMapping("/v2/shopping/cart")
public class LeaseShoppingCartV2Controller {

    @Resource
    private LeaseShoppingCartService leaseShoppingCartService;

    @ApiOperation("添加商品到购物车(批量+单个)")
    @PostMapping("/addGoodsV2")
    public Result<String> addGoodsV2(@RequestBody List<AddGoodsVo> addGoodsVoList) {
        return leaseShoppingCartService.addGoodsV2(addGoodsVoList);
    }

    @ApiOperation("查询购物车中商品列表")
    @PostMapping("/getGoodsListV2")
    public PageResult<ShopCartV2Dto> getGoodsListV2(@RequestBody(required = false) PageVo pageVo) {
        if (pageVo == null){
            pageVo = new PageVo();
        }
        return leaseShoppingCartService.getGoodsListV2(pageVo);
    }


    @ApiOperation("批量删除购物车中商品")
    @PostMapping("/deleteBatchGoodsV2")
    public Result<String> deleteBatchGoodsV2(@RequestBody List<CartInfoVo> baseVoList) {
        return leaseShoppingCartService.deleteBatchGoodsV2(baseVoList);
    }


    @ApiOperation("批量删除购物车中已下架商品")
    @PostMapping("/deleteBatchGoodsForIsDeleteV2")
    public Result<String> deleteBatchGoodsForIsDeleteV2() {
        return leaseShoppingCartService.deleteBatchGoodsForIsDeleteV2();
    }



}

