package com.ruoyi.mall.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mall.domain.Bo.staticDataBo;
import com.ruoyi.mall.domain.VipGuide;
import com.ruoyi.mall.service.IVipGuideService;
import com.ruoyi.mall.service.StaticDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.List;

@RestController
@RequestMapping("/mall/staticData")
public class StaticDataController  extends BaseController {

    @Autowired
    private StaticDataService staticDataService;


    private void setTableName(staticDataBo staticData){
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        staticData.setStartTime(staticData.getDateRange()[0]+" 00:00:00");
        staticData.setEndTime(staticData.getDateRange()[1]+" 24:60:60");
    }

    //来源渠道占比
    @GetMapping("/getIntroFree")
    public AjaxResult getIntroFree(staticDataBo staticData)
    {
        if(null != staticData.getDateRange()){
            setTableName(staticData);
        }
        return AjaxResult.success(staticDataService.getIntroFree(staticData));
    }
    //会员统计占比
    @GetMapping("/getYLife")
    public AjaxResult getYLife(staticDataBo staticData)
    {
        if(null != staticData.getDateRange()){
            setTableName(staticData);
        }
        return AjaxResult.success(staticDataService.getYLife(staticData));
    }
    //学校填报统计
    @GetMapping("/getSchool")
    public AjaxResult getSchool(staticDataBo staticData)
    {
        if(null != staticData.getDateRange()){
            setTableName(staticData);
        }
        return AjaxResult.success(staticDataService.getSchool(staticData));
    }
    //专业填报统计
    @GetMapping("/getMajor")
    public AjaxResult getMajor(staticDataBo staticData)
    {
        if(null != staticData.getDateRange()){
            setTableName(staticData);
        }
        return AjaxResult.success(staticDataService.getMajor(staticData));
    }
}
