package org.cs.mgr.sys.ctl;

import java.util.List;

import org.apache.log4j.Logger;
import org.cs.core.ctl.BaseCtl;
import org.cs.mgr.sys.model.Area;
import org.cs.mgr.sys.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @ClassName: AreaCtl 
 * @Description: TODO
 * @author: cosco gt.fan@msn.cn
 * @date: 2017年3月31日 下午5:28:50
 */
@Controller
@RequestMapping("/area")
public class AreaCtl extends BaseCtl{

	Logger log = Logger.getLogger(AreaCtl.class);
	
	@Autowired
	IAreaService areaService;
	
	@RequestMapping(value="getProvice", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
	@ResponseBody
	public String getProvice(ModelMap mm){
		List<Area> list = this.areaService.getProvice();
		return JSONObject.toJSONString(list, features);
	}
	
	@RequestMapping(value="getCityOrCountry", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
	@ResponseBody
	public String getCityOrCountry(String param, ModelMap mm){
		List<Area> list = this.areaService.getCityOrCountryByName(param);
		return JSONObject.toJSONString(list, features);
	}
	
	@RequestMapping(value="getByParentCode", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
	@ResponseBody
	public String getByParentCode(String param, ModelMap mm){
		List<Area> list = this.areaService.getCityOrCountry(param);
		return JSONObject.toJSONString(list, features);
	}
//	@RequestMapping(value="getProvice", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
//	@ResponseBody
//	public String getProvice(ModelMap mm){
//		List<Area> list = this.areaService.getProvice();
//		return JSONObject.toJSONString(list, features);
//	}
//	
//	@RequestMapping(value="getCityOrCountry", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
//	@ResponseBody
//	public String getCityOrCountry(String code, ModelMap mm){
//		List<Area> list = this.areaService.getCityOrCountry(code);
//		return JSONObject.toJSONString(list, features);
//	}
//	
	
}
