package com.bonus.system.index.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.log.annotation.Log;
import com.bonus.common.log.enums.BusinessType;
import com.bonus.system.index.entity.MapBean;
import com.bonus.system.index.service.HomePageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 首页
 *
 * @author zys
 */
@RestController
@RequestMapping("/homePage")
@Slf4j
public class HomePageController extends BaseController {

    @Resource(name = "homePageService")
    private HomePageService homePageService;

    /**
     * 首页数据
     */
    @PostMapping("/getHomePageData")
    @Log(title = "首页查询", businessType = BusinessType.QUERY)
    public AjaxResult getHomePageData(@RequestBody MapBean date) {
        try{
            return success(homePageService.getHomePageData(date.getDate()));
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return error("系统异常");
    }

    /**
     * 地图查询
     */
    @PostMapping("/getMapData")
    @Log(title = "地图查询", businessType = BusinessType.QUERY)
    public AjaxResult getMapData() {
        try{
            return success(homePageService.getMapData());
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return error("系统异常");
    }

}
