package com.ruoyi.web.modules.openstats.controller;

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 com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.modules.openstats.service.IMallStatsOpenService;

/**
 * 商城数据统计 Open API
 */
@RestController
@RequestMapping("/api/open/stats")
public class MallStatsOpenController extends BaseController
{
    @Autowired
    private IMallStatsOpenService mallStatsOpenService;

    @Anonymous
    @GetMapping("/categorySales")
    public AjaxResult categorySales(@RequestParam(value = "statDate", required = false) String statDate)
    {
        return success(mallStatsOpenService.getCategorySales(statDate));
    }

    @Anonymous
    @GetMapping("/hotCategoryRank")
    public AjaxResult hotCategoryRank(@RequestParam(value = "statDate", required = false) String statDate)
    {
        return success(mallStatsOpenService.getHotCategoryRank(statDate));
    }

    @Anonymous
    @GetMapping("/orderTrend")
    public AjaxResult orderTrend(@RequestParam(value = "statYear", required = false) String statYear)
    {
        return success(mallStatsOpenService.getOrderTrend(statYear));
    }

    @Anonymous
    @GetMapping("/shopEntry")
    public AjaxResult shopEntry(@RequestParam(value = "statYear", required = false) String statYear)
    {
        return success(mallStatsOpenService.getShopEntry(statYear));
    }

    @Anonymous
    @GetMapping("/regionRank")
    public AjaxResult regionRank(@RequestParam(value = "statYear", required = false) String statYear)
    {
        return success(mallStatsOpenService.getRegionRank(statYear));
    }

    @Anonymous
    @GetMapping("/reviewWordCloud")
    public AjaxResult reviewWordCloud()
    {
        return success(mallStatsOpenService.getReviewWordCloud());
    }

    @Anonymous
    @GetMapping("/overview")
    public AjaxResult overview(
            @RequestParam(value = "statDate", required = false) String statDate,
            @RequestParam(value = "statYear", required = false) String statYear)
    {
        return success(mallStatsOpenService.getOverview(statDate, statYear));
    }
}
