package com.wechat.service;

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

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.beust.jcommander.internal.Lists;
import com.wechat.dao.MdeHotelSubBrandDao;
import com.wechat.model.dbEntity.MdeHotelSubBrand;
import com.wechat.model.dto.HotelSubBrandDto;

@Service
public class MdeHotelSubBrandService {

	@Resource
	private MdeHotelSubBrandDao mdeHotelSubBrandDao;

	// 根据国际区分获取酒店品牌
	public List<MdeHotelSubBrand> getHotelByInternational(Map<String, String> map) {
		return mdeHotelSubBrandDao.getHotelByInternational(map);
	}

	/**
	 * 获取所有酒店品牌并分组
	 * @param language 语言类型
	 * @return
	 */
	public List<HotelSubBrandDto> getAllHotelSubBrandInternational(String language) {
		List<HotelSubBrandDto> listHotelDto = Lists.newArrayList();
		HotelSubBrandDto hotelDto = new HotelSubBrandDto();
		List<MdeHotelSubBrand> list = mdeHotelSubBrandDao.getAllHotelSubBrandInternational(language);
		// 0.所有
		hotelDto.setInternational("0");
		hotelDto.setListHotelSubBrand(list);
		listHotelDto.add(hotelDto);
		// 1.国际
		List<MdeHotelSubBrand> list1 = Lists.newArrayList();

		// 2.国内
		List<MdeHotelSubBrand> list2 = Lists.newArrayList();
		for (MdeHotelSubBrand mdeHotelSubBrand : list) {
			if (mdeHotelSubBrand.getInternational().equals("1")) {
				list1.add(mdeHotelSubBrand);
			}

			if (mdeHotelSubBrand.getInternational().equals("2")) {
				list2.add(mdeHotelSubBrand);
			}
		}
		HotelSubBrandDto hotelDto1 = new HotelSubBrandDto();
		hotelDto1.setInternational("1");
		hotelDto1.setListHotelSubBrand(list1);
		listHotelDto.add(hotelDto1);
		HotelSubBrandDto hotelDto2 = new HotelSubBrandDto();
		hotelDto2.setInternational("2");
		hotelDto2.setListHotelSubBrand(list2);
		listHotelDto.add(hotelDto2);
		return listHotelDto;
	}
}
