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

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.model.phoenix.PhoenixSalesOnSaleProject;
import cn.com.countrygarden.bi.main.service.phoenix.PhoenixSalesOnSaleProjectService;
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;

import java.util.List;
import java.util.Map;

@Controller("datavPhoenixSalesOnSaleProjectController")
@RequestMapping("/api/phoenix/onsale/project")
public class PhoenixSalesOnSaleProjectController {

    @Autowired
    private PhoenixSalesOnSaleProjectService projectService;


    /**
     * 同步项目
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/sync", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public Object sync(@RequestParam(name = "start", defaultValue = "") String startDate,
                       @RequestParam(name = "end", defaultValue = "") String endDate,
                       @RequestParam(name = "roomSort", defaultValue = "房屋") String roomSort) {
        List<PhoenixSalesOnSaleProject> onSaleProjects = projectService.persistence(startDate, endDate, roomSort);

        return Response.response(onSaleProjects);
    }
}
