package com.cloudcross.ssp.back.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudcross.ssp.back.model.Location;
import com.cloudcross.ssp.back.service.ILocationService;
import com.cloudcross.ssp.base.dao.GenericIBatisDao;

@Service
public class LocationService implements ILocationService{

	
	@Autowired
	private GenericIBatisDao ibatisDao;

	@Override
	public List<Location> findAll(String country) {
	 
		return ibatisDao.getList("back.locationSqlMapper.findAll",country);
	}
	
	@Override
	public List<Location> findByProvince(String str) {
		// TODO Auto-generated method stub
		str = str.toUpperCase();
		if(str.length()==4){
			HashMap <String ,String > hashMap = new HashMap<String ,String> ();
			hashMap.put("location1", str.substring(0,2));
			hashMap.put("location2", str.substring(2,4));
			System.out.println(hashMap.toString());
			return 	ibatisDao.getList("back.locationSqlMapper.findByProvince",hashMap);	
		}
		return null;
	}	
	
	@Override
	public Location findByLocationT(String locationT) {
		return ibatisDao.get("back.locationSqlMapper.findByLocationT", locationT);
		
	}	
}