package com.heyu.api.controller.mm;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heyu.api.alibaba.request.mm.order.resp.ShippingCartRequest;
import com.heyu.api.common.annotation.Describe;
import com.heyu.api.data.dao.vv.VvShoppingCartDao;
import com.heyu.api.data.utils.R;
import com.heyu.api.utils.ISelect;
import com.heyu.api.utils.PPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mm/shipping/cat")
public class AdminShoppingCartController {


    @Autowired
    private VvShoppingCartDao vvShoppingCartDao;

    @Describe("后台购物车列表")
    @RequestMapping("/list")
    public R list(ShippingCartRequest vvShoppingCartRequest) {
        PPageUtils pageUtils = PPageUtils.startPage(vvShoppingCartRequest.getPageNum(), vvShoppingCartRequest.getPageSize())
                .doSelect(new ISelect() {
                    @Override
                    public List doSelect(IPage page) {
                        return vvShoppingCartDao.selectByCondition(page,
                                vvShoppingCartRequest.getProductName(),
                                vvShoppingCartRequest.getBuyerPhone(),
                                vvShoppingCartRequest.getBuyerName(),
                                vvShoppingCartRequest.getBuyerWeixin()
                        );
                    }
                });
        return R.ok().setData(pageUtils);
    }
}
