package com.gree.mall.miniapp.controller.renovation;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.annotation.ApiNotAuth;
import com.gree.mall.miniapp.bean.goods.GoodsNewBean;
import com.gree.mall.miniapp.bean.order.OrderCommentBean;
import com.gree.mall.miniapp.exception.RemoteServiceException;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.renovation.RenovationLogic;
import com.gree.mall.miniapp.plus.entity.AdminCompanyWechatTemplate;
import com.gree.mall.miniapp.plus.entity.GoodsNewsCategory;
import com.gree.mall.miniapp.plus.entity.OrderShare;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@RestController
@Api(value = "装修模块", tags ={"装修模块"} )
@RequestMapping(value = "/renovation", produces = "application/json; charset=utf-8")
public class RenovationController {


    @Autowired
    RenovationLogic renovationLogic;

    @ApiNotAuth
    @GetMapping("/detail")
    @ApiOperation("装修内容详情")
    public ResponseHelper<AdminCompanyWechatTemplate> detail(
            HttpServletRequest request
    ) throws RemoteServiceException {
        AdminCompanyWechatTemplate detail = renovationLogic.detail(request);
        return ResponseHelper.success(detail);
    }

    @ApiNotAuth
    @GetMapping("/category/list")
    @ApiOperation("精选类别")
    public ResponseHelper<IPage<GoodsNewsCategory>> categoryList(
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNo,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize,
            HttpServletRequest request
    ) throws RemoteServiceException {

        IPage<GoodsNewsCategory> goodsNewsCategoryIPage = renovationLogic.categoryList(request, pageNo, pageSize);
        return ResponseHelper.success(goodsNewsCategoryIPage);
    }


    @ApiNotAuth
    @GetMapping("/goods/list")
    @ApiOperation("精选分类商品列表")
    public ResponseHelper<IPage<GoodsNewBean>> goodsList(
            @ApiParam(value = "objId",required = false) @RequestParam(required = false) String objId,
            @ApiParam(
                    value = "类型(1=新维度分类，2=首页弹窗， 3=活动专区1，4=活动专区2左侧，5=活动专区2右侧，6=专场专区1，7=专场专区2 ， 8=专场专区3 ， 9=专场专区4)",
                    required = true) @RequestParam(required = true
            ) String type,
            @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false,defaultValue = "0") Integer sort,
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNo,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize,
            HttpServletRequest request
    ) throws RemoteServiceException {

        IPage<GoodsNewBean> goodsNewBeanIPage = renovationLogic.queryNewGoods(request, objId , type, pageNo, pageSize,sort);
        return ResponseHelper.success(goodsNewBeanIPage);
    }


    @ApiNotAuth
    @GetMapping("/settle/list")
    @ApiOperation("结算公告")
    public ResponseHelper<List<OrderShare>> settleList(
            HttpServletRequest request
    ) throws RemoteServiceException {

        List<OrderShare> orderShares = renovationLogic.settleList(request);
        return ResponseHelper.success(orderShares);
    }


}
