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.AppletIndexService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.commonAddOrder.entity.CommonAddOrder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags="首页接口")
@RestController
@RequestMapping("/index")
@Slf4j
public class AppletIndexController {

    @Resource
    private AppletIndexService appletIndexService;


    //获取banner
    @ApiOperation(value="获取banner", notes="获取banner")
    @GetMapping("/getBanner")
    public Result<?> getBanner(){
        return appletIndexService.getBanner();
    }


    //获取金刚区icon
    @ApiOperation(value="获取金刚区icon", notes="获取金刚区icon")
    @GetMapping("/getIcon")
    public Result<?> getIcon(){
        return appletIndexService.getIcon();
    }

    //获取分类
    @ApiOperation(value="获取分类", notes="获取分类")
    @GetMapping("/getClassify")
    public Result<?> getClassify(){
        return appletIndexService.getClassify();
    }


    //获取城市
    @ApiOperation(value="获取城市", notes="获取城市")
    @GetMapping("/getCity")
    public Result<?> getCity(){
        return appletIndexService.getCity();
    }



    //获取建材商品信息列表
    @ApiOperation(value="获取建材商品信息列表", notes="获取建材商品信息列表")
    @GetMapping("/getProductList")
    public Result<?> getProductList(String cityId,String shopIconId, String shopClassId, PageBean pageBean){
        return appletIndexService.getProductList(cityId,shopIconId,shopClassId,pageBean);
    }


    //获取商品信息详情
    @ApiOperation(value="获取商品信息详情", notes="获取商品信息详情")
    @GetMapping("/getProductDetail")
    public Result<?> getProductDetail(String productId){
        return appletIndexService.getProductDetail(productId);
    }

    //根据用户登录信息获取当前是否有快捷下单订单
    @ApiOperation(value="根据用户登录信息获取当前是否有快捷下单订单", notes="根据用户登录信息获取当前是否有快捷下单订单")
    @GetMapping("/getOrderInfo")
    public Result<?> getOrderInfo(@RequestHeader("X-Access-Token") String token){
        return appletIndexService.getOrderInfo(token);
    }


    //快捷下单-拍照下单/语音下单
    @ApiOperation(value="快捷下单-拍照下单/语音下单", notes="快捷下单-拍照下单/语音下单")
    @PostMapping("/addOrder")
    public Result<?>  addOrder(@RequestHeader("X-Access-Token") String token, CommonAddOrder commonAddOrder){
        return appletIndexService.addOrder(token,commonAddOrder);
    }

    //取消快捷订单
    @ApiOperation(value="取消快捷订单", notes="取消快捷订单")
    @PostMapping("/cancelOrder")
    public Result<?> cancelOrder(@RequestHeader("X-Access-Token") String token,String orderId){
        return appletIndexService.cancelOrder(token,orderId);
    }









    //创建订单
    @ApiOperation(value="创建订单", notes="创建订单")
    @PostMapping("/createOrder")
    public Result<?> createOrder(@RequestHeader("X-Access-Token") String token,Integer payType,String productId,String addressId,Integer orderNum){
        return appletIndexService.createOrder(token,payType,productId,addressId,orderNum);
    }


    //立即支付
    @ApiOperation(value="立即支付", notes="立即支付")
    @PostMapping("/payOrder")
    public Result<?> payOrder(@RequestHeader("X-Access-Token") String token,Integer type,String orderId){
        return appletIndexService.payOrder(token,type,orderId);
    }




    //快捷订单列表数据带分页
    @ApiOperation(value="快捷订单列表数据带分页", notes="快捷订单列表数据带分页")
    @GetMapping("/getAddOrderPageBean")
    public Result<?> getAddOrderPageBean(@RequestHeader("X-Access-Token") String token,String state, PageBean pageBean){
        return appletIndexService.getAddOrderPageBean(token,state,pageBean);
    }

    //查询快捷订单详情
    @ApiOperation(value="查询快捷订单详情", notes="查询快捷订单详情")
    @GetMapping("/getAddOrderInfo")
    public Result<?> getAddOrderInfo(@RequestHeader("X-Access-Token") String token,String orderId){
        return appletIndexService.getAddOrderInfo(token,orderId);
    }











}
