
package com.wzj.soopin.statistics.controller;

import com.wzj.soopin.statistics.entity.dto.GoodsStatisticsQueryParam;
import com.wzj.soopin.statistics.entity.dto.StatisticsQueryParam;
import com.wzj.soopin.statistics.entity.enums.StatisticsQuery;
import com.wzj.soopin.statistics.entity.vo.GoodsStatisticsDataVO;
import com.wzj.soopin.statistics.entity.vo.IndexNoticeVO;
import com.wzj.soopin.statistics.entity.vo.IndexStatisticsVO;
import com.wzj.soopin.statistics.entity.vo.StoreStatisticsDataVO;
import com.wzj.soopin.statistics.service.IndexStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
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.RestController;

import java.util.List;

/**
 * 管理端,首页统计数据接口
 *
 * @author Bulbasaur
 * @since 2020/12/15 17:53
 */
@Slf4j
@Tag(name = "管理端,首页统计数据接口")
@RestController
@RequestMapping("/manager/statistics/index")
public class IndexStatisticsManagerController {

    /**
     * 首页统计
     */
    @Autowired
    private IndexStatisticsService indexStatisticsService;

    @Operation(summary = "获取首页查询数据")
    @GetMapping
    public R<IndexStatisticsVO> index() {
        try {
            return R.ok(indexStatisticsService.indexStatistics());
        } catch (Exception e) {
            log.error("获取首页查询数据错误",e);
        }
        return null;
    }

    @Operation(summary = "获取首页查询热卖商品TOP10")
    @GetMapping("/goodsStatistics")
    public R<List<GoodsStatisticsDataVO>> goodsStatistics(GoodsStatisticsQueryParam goodsStatisticsQueryParam) {

        //按照金额查询
        goodsStatisticsQueryParam.setType(StatisticsQuery.PRICE.name());
        return R.ok(indexStatisticsService.goodsStatistics(goodsStatisticsQueryParam));
    }

    @Operation(summary = "获取首页查询热卖店铺TOP10")
    @GetMapping("/storeStatistics")
    public R<List<StoreStatisticsDataVO>> storeStatistics(StatisticsQueryParam statisticsQueryParam) {
        return R.ok(indexStatisticsService.storeStatistics(statisticsQueryParam));
    }

    @Operation(summary = "通知提示信息")
    @GetMapping("/notice")
    public R<IndexNoticeVO> notice() {
        return R.ok(indexStatisticsService.indexNotice());
    }
}
