package com.njzscloud.supervisory.bs.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.supervisory.bs.service.StatisticsService;
import com.njzscloud.supervisory.bs.service.SupervisionStatisticsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/statistics")
@RequiredArgsConstructor
public class StatisticsController {
    private final StatisticsService statisticsService;
    private final SupervisionStatisticsService supervisionStatisticsService;


    @GetMapping("/obtain_data")
    public R<?> obtainData() throws Exception {
        long l = System.currentTimeMillis();
        Map<String, Object> data = statisticsService.obtainData();
        System.out.println("耗时: " + (System.currentTimeMillis() - l));
        return R.success(data);
    }

    @GetMapping("/obtain_order")
    public R<?> obtainOrder(Long userId) {
        return R.success(statisticsService.obtainOrder(userId));
    }

    @GetMapping("/supervision/obtain_data")
    public R<?> obtainData1() {
        long l = System.currentTimeMillis();
        Map<String, Object> data = supervisionStatisticsService.obtainData();
        System.out.println("耗时: " + (System.currentTimeMillis() - l));
        return R.success(data);
    }

}
