package org.jeecg.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.api.bean.PageBean;
import org.jeecg.api.service.AppletCatService;
import org.jeecg.api.service.AppletIndexService;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags="购物车相关接口")
@RestController
@RequestMapping("/cat")
@Slf4j
public class AppletCatController {

    @Resource
    private AppletCatService apiRiceService;


    //获取购物车信息列表带分页
    @ApiOperation(value="获取购物车信息列表带分页", notes="获取购物车信息列表带分页")
    @GetMapping(value = "/getCartPageList")
    public Result<?> getCartPageList(@RequestHeader("X-Access-Token") String token, PageBean pageBean){
        return apiRiceService.getCartPageList(token,pageBean);
    }

    //加入购物车 传入token shopId num
    @ApiOperation(value="加入购物车 传入token shopId num", notes="加入购物车 传入token shopId num")
    @GetMapping(value = "/addCart")
    public Result<?> addCart(@RequestHeader("X-Access-Token") String token, String shopId, Integer num){
        return apiRiceService.addCart(token,shopId,num);
    }


    //删除购物车信息
    @ApiOperation(value="删除购物车信息", notes="删除购物车信息")
    @PostMapping(value = "/deleteCart")
    public Result<?> deleteCart(@RequestHeader("X-Access-Token") String token,String ids){
        return apiRiceService.deleteCart(token,ids);
    }


    //修改购物车信息数量
    @ApiOperation(value="修改购物车信息数量", notes="修改购物车信息数量")
    @PostMapping(value = "/updateCartNum")
    public Result<?> updateCartNum(@RequestHeader("X-Access-Token") String token,String id,Integer num){
        return apiRiceService.updateCartNum(token,id,num);
    }












}
