package com.gree.mall.manager.controller.count;

import com.gree.mall.manager.bean.count.IncreCount;
import com.gree.mall.manager.bean.count.MaterialCount;
import com.gree.mall.manager.bean.count.RepairProjectCount;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.count.CountLogic;
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 javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@Api(value = "数据看板", tags ={"数据看板"} )
@RequestMapping(value = "/dataCount", produces = "application/json; charset=utf-8")
public class DataCountController {


    @Autowired
    CountLogic countLogic;

    @GetMapping("/repairProject")
    @ApiOperation(value = "工程维保首页")
    public ResponseHelper<RepairProjectCount> repairProject(HttpServletRequest request) {
        RepairProjectCount repairProjectCount = countLogic.repairProject(request);
        return ResponseHelper.success(repairProjectCount);
    }


    @GetMapping("/increCount")
    @ApiOperation(value = "增值服务首页")
    public ResponseHelper<IncreCount> increCount(
            @ApiParam(value = "开始时间",required = false) @RequestParam(required = false) String startTime,
            @ApiParam(value = "结束时间",required = false) @RequestParam(required = false) String endTime,

            HttpServletRequest request) {
        IncreCount increCount = countLogic.increCount(startTime,endTime,request);
        return ResponseHelper.success(increCount);
    }


    @GetMapping("/materialCount")
    @ApiOperation(value = "辅材配件首页")
    public ResponseHelper<MaterialCount> materialCount(

            HttpServletRequest request) {
        MaterialCount materialCount = countLogic.materialCount(request);
        return ResponseHelper.success(materialCount);
    }

}
