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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.annotation.ApiNotAuth;
import com.gree.mall.miniapp.bean.chargingstandard.ChargingStandardBean;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.charging.ChargingStandardLogic;
import com.gree.mall.miniapp.plus.entity.Brand;
import com.gree.mall.miniapp.plus.entity.ChargingStandardType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "收费标准/故障排查API", tags ={"收费标准/故障排查API"} )
@RequestMapping(value = "/charging", produces = "application/json; charset=utf-8")
public class ChargingStandardController {


    @Autowired
    ChargingStandardLogic chargingStandardLogic;

    @ApiNotAuth
    @GetMapping("/brand/list")
    @ApiOperation("品牌-列表")
    public ResponseHelper<Brand> brandList(){
        List<Brand> brands = chargingStandardLogic.brandList();
        return ResponseHelper.success(brands);
    }

    @ApiNotAuth
    @GetMapping("/type/list")
    @ApiOperation("收费标准分类-列表")
    public ResponseHelper<List<ChargingStandardType>> typeList(){
        List<ChargingStandardType> chargingStandardTypes = chargingStandardLogic.listType();
        return ResponseHelper.success(chargingStandardTypes);

    }

    @ApiNotAuth
    @GetMapping("/list")
    @ApiOperation("收费标准/故障排查-列表")
    public ResponseHelper<List<ChargingStandardBean>> list(
            @ApiParam("分类id") @RequestParam String twoCategoryId,
            @ApiParam(value = "品牌id",required = false) @RequestParam(required = false) String brandId,
            @ApiParam(value = "业务类型id",required = false) @RequestParam(required = false) String chargingStandardTypeId,
            @ApiParam("1=收费标准 2=故障排查") @RequestParam Integer type,
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize
    ){
        //brandId = null;
        IPage<ChargingStandardBean> list = chargingStandardLogic.list(twoCategoryId,brandId,chargingStandardTypeId, type, pageNum, pageSize);
        return ResponseHelper.success(list);
    }

    @ApiNotAuth
    @GetMapping("/detaillist")
    @ApiOperation("收费标准/故障排查-详情列表")
    public ResponseHelper<List<ChargingStandardBean>> detaillist(
            @ApiParam(value = "分类id",required = true) @RequestParam String twoCategoryId,
            @ApiParam(value = "品牌id",required = true) @RequestParam String brandId,
            @ApiParam(value = "业务类型id",required = true) @RequestParam String chargingStandardTypeId,
            @ApiParam(value = "1=收费标准 2=故障排查",required = true) @RequestParam Integer type,
            @ApiParam(value = "故障内容",required = true) @RequestParam String content1
    ){
        //brandId = null;
        List<ChargingStandardBean> detaillist = chargingStandardLogic.detaillist(twoCategoryId, brandId, chargingStandardTypeId, type, content1);
        return ResponseHelper.success(detaillist);
    }

    @ApiNotAuth
    @GetMapping("/detail")
    @ApiOperation("收费标准/故障排查-详情")
    public ResponseHelper<ChargingStandardBean> typeList(
            @ApiParam("id") @RequestParam String id
    ){
        ChargingStandardBean bean = chargingStandardLogic.detail(id);
        return ResponseHelper.success(bean);
    }


}
