package com.lightinit.hsdatashow.controller.admin;

import com.lightinit.hsdatashow.entity.GarbageTreatment;
import com.lightinit.hsdatashow.model.admin.GarbageNameAndValueModel;
import com.lightinit.hsdatashow.model.admin.GarbageRegionResultModel;
import com.lightinit.hsdatashow.model.admin.GarbageTrendResultModel;
import com.lightinit.hsdatashow.model.admin.GarbagedangerTrendResultModel;
import com.lightinit.hsdatashow.service.admin.IGarbageServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigDecimal;

@Controller
@RequestMapping(value = "/admin/garbage")
public class GarbageController {

    @Autowired
    private IGarbageServer garbageServer ;

    @RequestMapping("/index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("admin/garbage/index") ;
        return modelAndView ;
    }

    @RequestMapping("/getGarbageTreatment.action")
    @ResponseBody
    public GarbageNameAndValueModel getGarbageTreatment(){
        GarbageTreatment garbageTreatment = garbageServer.getGarbageTreatment() ;
        GarbageNameAndValueModel garbageNameAndValueModel = new GarbageNameAndValueModel("最新处理率",garbageTreatment.getTreatmentRate()) ;
        return garbageNameAndValueModel ;
    }

    @RequestMapping("/getGarbageRegion.action")
    @ResponseBody
    public GarbageRegionResultModel getGarbageRegion(){
        return garbageServer.getGarbageRegion() ;
    }

    @RequestMapping("/getGarbagedangerRegion.action")
    @ResponseBody
    public BigDecimal getGarbagedangerRegion(){
        return garbageServer.getGarbagedangerRegion() ;
    }

    @RequestMapping("/getGarbageTrend.action")
    @ResponseBody
    public GarbageTrendResultModel getGarbageTrend(){
        return garbageServer.getGarbageTrend() ;
    }

    @RequestMapping("/getGarbagedangerTrend.action")
    @ResponseBody
    public GarbagedangerTrendResultModel getGarbagedangerTrend(){
        return garbageServer.getGarbagedangerTrend() ;
    }

}
