package com.goafanti.common.constant;

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

import com.goafanti.common.utils.StringUtils;

public class PageConstants {
	static final Map<String,String> WEB_DEMAND_PAGES = new HashMap<String, String>();
	static final Map<String,String> APP_DEMAND_PAGES = new HashMap<String, String>();
	static final Map<String,String> WEB_ACHIEVEMENT_PAGES = new HashMap<String, String>();
	static final Map<String,String> APP_ACHIEVEMENT_PAGES = new HashMap<String, String>();
	public static final int WEB_PLATFORM = 0;
	public static final int APP_PLATFORM = 1;
	public static final String DEFAULT_DOMAIN = "jishutao.com";
	public static final int DEFAULT_TOP_NUMBER = 9999999;
	public static final int DEFAULT_SHOW_NUMBER = 9999999;
	static{
		WEB_DEMAND_PAGES.put("web_index", "网站首页");
		WEB_DEMAND_PAGES.put("web_demand_main", "网站需求页主页");
		WEB_DEMAND_PAGES.put("web_demand_list", "网站需求列表页");
		APP_DEMAND_PAGES.put("app_index", "APP首页");
		APP_DEMAND_PAGES.put("app_demand_main", "APP需求页主页");
		APP_DEMAND_PAGES.put("app_demand_list", "APP需求列表页");	
		WEB_ACHIEVEMENT_PAGES.put("web_index", "网站首页");
		WEB_ACHIEVEMENT_PAGES.put("web_achievement_main", "网站成果主页");
		WEB_ACHIEVEMENT_PAGES.put("web_achievement_list", "网站成果列表页");
		APP_ACHIEVEMENT_PAGES.put("app_index", "网站首页");
		APP_ACHIEVEMENT_PAGES.put("app_achievement_main", "APP成果主页");
		APP_ACHIEVEMENT_PAGES.put("app_achievement_list", "APP成果列表页");
	}

	public static boolean containPage(String page,Map<String,String> matchPages){
		if(StringUtils.isBlank(page)) return false;
		return matchPages.keySet().contains(page);
	}
	
	public static void putDemand(String[] pages,List<String> webPages,List<String> appPages){
		if(pages == null || pages.length <= 0) return;
		for(String page : pages){
			if(containPage(page,WEB_DEMAND_PAGES)){
				webPages.add(page);
			}
			if(containPage(page,APP_DEMAND_PAGES)){
				appPages.add(page);
			}
		}
	}
	
	public static void putAchievement(String[] pages,List<String> webPages,List<String> appPages){
		if(pages == null || pages.length <= 0) return;
		for(String page : pages){
			if(containPage(page,WEB_ACHIEVEMENT_PAGES)){
				webPages.add(page);
			}
			if(containPage(page,APP_ACHIEVEMENT_PAGES)){
				appPages.add(page);
			}
		}
	}
}
