package com.supplier.controller;

import com.supplier.model.HomePageIndex;
import com.supplier.service.HomePageService;
import com.supplier.util.ParsingToken;
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 javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 *  首页查询操作
 */
@RestController
@RequestMapping("homePageIndex")
public class HomePageController {

    @Autowired
    private HomePageService homePageService;

    /**
     * 查询首页报价单 跟 成交单数据数量 跟 当前年报价单统计
     * @param homePageIndex 参数对象
     * @param request token内容
     * @return 返回结果
     */
    @GetMapping("getHeadData")
    public Map<String, Object> getHeadData(HomePageIndex homePageIndex, HttpServletRequest request){
        homePageIndex.setCode((String)ParsingToken.tokenParsing(request).get("code"));
        return homePageService.getHeadData(homePageIndex);
    }
}
