package cn.com.countrygarden.bi.main.controller.v2;

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysOrgan;
import cn.com.countrygarden.bi.main.service.twerp.hm.TbDesktop经营主题停车收入Service;
import cn.com.countrygarden.bi.main.service.twerp.hm.TbSysUserService;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller("parkingDataControllerV2")
@RequestMapping("/api/biapp/data/v2/parking")
public class ParkingDataController {

    @Autowired
    private TbSysUserService userService;
    @Autowired
    private TbDesktop经营主题停车收入Service service;

    /**
     * 停车场收入
     *
     * @return
     */
    @RequestMapping(value = "/overview", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    @ResponseBody
    public Object overview(@RequestParam(value = "CommID", defaultValue = "") String commID,
                           @RequestParam(value = "OrganCode", defaultValue = "") String organCode) {
        TbSysOrgan sysOrgan = userService.getSysOrgan();
        if (sysOrgan == null) {
            return Response.response();
        }
        return Response.response(service.sumByUserCodeFromCache(
                sysOrgan,
                organCode,
                commID
        ));
    }

}
