package com.wechat.service;

import java.util.List;

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

import com.wechat.dao.SysDictDao;
import com.wechat.model.responseDto.DPResp;
import com.wechat.model.responseDto.LVResp;
import com.wechat.model.responseDto.PhoneCodeResp;

@Service
public class SysDictService {

	@Autowired
	private SysDictDao sysDiceDao;

	/**
	 * 根据省份城市区域分组
	 * 
	 * @return
	 *//*
	public List<Province> groupByProvinceAndCity() {
		// 获取所有的省份
		List<SysDict> AllProvice = sysDiceDao.getAllProvice();
		// 获取所有省份Id
		List<String> proviceIdList = Lists.transform(AllProvice, new Function<SysDict, String>() {
			@Override
			public String apply(SysDict arg0) {
				return arg0.getId();
			}
		});
		// 获取所有城市
		List<SysDict> allCities = sysDiceDao.getAllCities(proviceIdList);
		// 获取所有城市Id
		List<String> citiesIdList = Lists.transform(allCities, new Function<SysDict, String>() {
			@Override
			public String apply(SysDict arg0) {
				return arg0.getId();
			}
		});
		// 获取城市并根据省份分组
		ImmutableListMultimap<String, SysDict> groupCity = Multimaps.index(allCities, new Function<SysDict, String>() {
			@Override
			public String apply(SysDict arg0) {
				return arg0.getParentId();
			}
		});
		// 获取所有区域
		List<SysDict> allArea = sysDiceDao.getAllArea(citiesIdList);
		// 获取所有区域并根据城市分组
		ImmutableListMultimap<String, SysDict> groupArea = Multimaps.index(allArea, new Function<SysDict, String>() {
			@Override
			public String apply(SysDict arg0) {
				return arg0.getParentId();
			}
		});
		// 组织List<Province>
		List<Province> listPro = Lists.newArrayList();
		for (SysDict sysDictPro : AllProvice) {
			Province pro = new Province();
			pro.setValue(sysDictPro.getValue());
			pro.setName(sysDictPro.getLabel());
			if (groupCity.containsKey(sysDictPro.getId())) {
				List<SysDict> sysDictList = groupCity.get(sysDictPro.getId().toString());
				List<City> cityList = Lists.newArrayList();
				for (SysDict sysDict : sysDictList) {
					City city = new City();
					city.setValue(sysDict.getValue());
					city.setName(sysDict.getLabel());
					List<AreaDto> areaList = Lists.newArrayList();
					if (groupArea.containsKey(sysDict.getId())) {
						List<SysDict> sysCityList = groupArea.get(sysDict.getId());
						for (SysDict sysDict2 : sysCityList) {
							AreaDto area = new AreaDto();
							area.setValue(sysDict2.getValue());
							area.setName(sysDict2.getLabel());
							areaList.add(area);
						}
						city.setChildren(areaList);
					}
					cityList.add(city);
				}
				pro.setChildren(cityList);
			}
			listPro.add(pro);
		}
		return listPro;
	}*/

	/**
	 * 获取部门信息
	 * 
	 * @return
	 */
	public List<DPResp> getDictByType(String type,String lang) { 
		return sysDiceDao.getDictByType(type,lang);
	}
	public List<LVResp> getDictLVByType(String type,String lang) { 
		return sysDiceDao.getDictLVByType(type,lang);
	}
	
	/**
	 * 国家手机区号码 （如中国+86）
	 * @param type
	 * @param lang
	 * @return
	 */
	public List<PhoneCodeResp> getPhoneCode(String type,String lang) { 
		return sysDiceDao.getPhoneCode(type,lang);
	}
}
