var project_name, project_attr, projects = {},
	java_projects = [],
	node_projects = [],
	python_projects = [],
	ui_projects = [];
var param = {
	type: "",
	name: "",
	attr: ""
}
// var users = [{}, {
// 	name: "dekun.dai",
// 	pwd: "quantgroup.com"
// }, {
// 	name: "dekun.dai",
// 	pwd: "quantgroup.com"
// }];

var pClass = function() {};
pClass.prototype = {
		init: function(group, isActive, projectType, port, url, projectName, gitPathHead, logName, configFile, command, nodeVersion, userIndex, desc, auth, command2, java_target_path) {
			this.project_group = group; //项目所属组  1: 技术部  2: 数据部
			this.name = projectName; //项目名称
			this.type = projectType; //项目类型
			// this.www = www;
			this.url=url;    //项目线上域名
			// this.gitPathHead = gitPathHead; //项目git 路径头
			if (group == 1){//技术部地址
				this.git_path = "git@git.quantgroup.cn:" + gitPathHead + "/" + projectName + ".git"  //项目git路径地址
			}else if(group == 2){//数据部地址
				this.git_path = "git@gitabc.xyqb.com:" + gitPathHead + "/" + projectName + ".git"  //项目git路径地址
			}
			
			this.log_name = logName; // 项目日志位置
			this.config_file = configFile; //项目配置文件地址
			this.command = ""; //项目命令1
			this.command2 = command2; //项目命令2
			this.node_version = nodeVersion; //项目的node版本
			this.port = port; //项目占用端口
			this.desc = desc; //项目描述
			this.is_active = isActive; //项目是否必要项目
			this.auth = auth; // 项目负责人
			this.target_path = java_target_path; //项目java打包后的jar文件路径
			projects[projectName] = this;
			switch (projectType) {
				case "java":
					this.command = "java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/" + projectName + ".log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps  -jar " + projectName + ".jar " + command;
					java_projects.push(this);
					if (this.target_path == "") {
						this.target_path = "./target"
					}
					break;
				case "node":
					this.command = command;
					node_projects.push(this);
					break;
				case "ui":
					this.command = command;
					ui_projects.push(this);
					break;
				case "python":
					this.command = command;
					python_projects.push(this);
					break;
			}
		}
	}
	// --java
new pClass().init(1, true,"java", "7003", "api", "xyqb", "QG", "xyqb.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "现金贷-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1, true,"java", "7025", "btapi", "baitiao", "baitiao", "baitiao.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "baitiao-api/target");
new pClass().init(1,true,"java", "7019", "mallapi", "xyqb-mall", "QG", "mall.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "商城后台-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7010", "offapi", "xyqb-offline", "QG", "xyqb_offline.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "线下业务-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true,"java", "7042", "passportapi2", "xyqb-user2", "head_group", "xyqb_user.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "用户注册登录-V2-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false,"java", "7005", "rapi", "di-ting", "QG", "di_ting.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "风控审计-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7013", "auth", "han-gu-guan", "QG", "han-gu-guan.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "用户注册登录-V1-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7015", "rauth", "jian-men-guan", "QG", "jian_men_guan.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "信审服务-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true,"java", "7028", "pdf", "black-hole", "QG", "black-hole.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "合同中心-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false,"java", "7006", "payapi", "gu-bei", "funding", "pay-center.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "支付中心-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7023", "quartz", "xyqb-quartz", "QG", "quartz.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "定时任务-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,true,"java", "7021", "scapi", "spider-center", "QG", "spider-center.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "授信-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true,"java", "7037", "qapi", "cash-loan-flow", "QG", "cash_loan_flow.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "现金贷流量对接-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7012", "financial-api", "financial-system", "QG", "financial_system.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "财务系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,false, "java", "7034", "", "fund-manage", "QG", "fund_manage.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "债转系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false,"java", "7029", "gyxdapi", "gyxd", "QG", "gyxd.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "广源小贷-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7038", "merchantapi", "merchant-backend", "QG", "merchant.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "商户后台-server", "凌子华／陈东亮", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true,"java", "7031", "redpacket", "redpacket", "baitiao", "redpacket.log", "application.properties", "--worker 1 --currentWorker 1 -t > /dev/null 2>&1 &", null, 2, "红包系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,false, "java", "7044", "", "finance-api", "bo.wang", "finance-api.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "财务系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,false, "java", "7045", "", "check-accounts", "QG", "check_accounts.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "对账系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7014", "qunar", "du-jiang-yan", "QG", "du_jiang_yan.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "第三方对接导流-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "8051", "", "msg", "fund_pay", "msg.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "新版消息中心", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7052", "", "xyqb-btzt", "qg-op-backend", "xyqb-btzt.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投外部", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7053", "", "xyqb-btzt-internal", "qg-op-backend", "xyqb-btzt-internal.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投内部", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7060", "", "baitiao-op-backend", "baitiao", "baitiao-op-backend.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "运营系统服务", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "xyqb-backend/target");
new pClass().init(1,true, "java", "7062", "", "xyqb-user2-query", "head_group", "xyqb_user_query.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "用户系统查询服务", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,false, "java", "7063", "", "traffic-webapp", "qg-op-backend", "traffic.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "流量分发系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7017", "eureka.silkroad", "silk-road-eureka", "baitiao", "silk-road-eureka.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "Eureka 服务注册发现微服务", "魏巍", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7027", "", "silk-road-caller", "baitiao", "silk-road-caller.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "MQ消息调用中心微服务", "魏巍", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7056", "", "score", "baitiao", "score.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "积分系统", "刑志超", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7065", "", "silk-road-backman", "baitiao", "silk-road-backman.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投-对内系统2", "张曙", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7066", "", "silk-road", "baitiao", "silk-road.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投-对外系统2", "魏巍", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7059", "zt", "baitiao-zhitou", "baitiao", "baitiao-zhitou.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投-对接资金方", "张斌", "mvn clean package -Ptest -Dmaven.test.skip=true", "./xyqb-btzt-internal/target/");
new pClass().init(2,false, "java", "7068", "", "customer_helpdesk", "data-riskcontrol", "customer_helpdesk.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "外部客服-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7069", "", "notify", "fund_pay", "notify.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "支付中心消息通知系统-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7071", "", "mall-settlement", "baitiao", "mall-settlement.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "商户结算系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,true, "java", "7072", "", "data-taurus", "data-riskcontrol", "data-taurus.log", "application.properties", " /dev/null 2>&1 &", null, 2, "质保金-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(2,true, "java", "7074", "", "account-center", "QG", "account_center.log", "application.properties", " /dev/null 2>&1 &", null, 2, "账户中心-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(2,true, "java", "7079", "", "user_credit", "QG", "user_credit.log", "application.properties", " /dev/null 2>&1 &", null, 2, "用户升级-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(2,true, "java", "7076", "", "urge_dispatcher", "data-riskcontrol", "dispatcher.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "催收系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,true, "java", "7081", "", "wechat-config", "fund_pay", "wechat-config.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "微信消息推送系统", "",     "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(2,false, "java", "7082", "", "clotho", "funding", "clotho.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &",     null, 2, "资金方统计相关功能", "",     "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7085", "", "mall-canal", "baitiao", "mall_canal.log", "application.properties", "-l 152 -w 2 &", null, 2, "商城订单监控", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(1,false, "java", "7087", "", "xyqb-display", "baitiao", "display.log", "application.properties", "&", null, 2, "信用钱包显示配置", "陈东亮", "mvn clean package -Ptest     -Dmaven.test.skip=true", "./display-api/target/");
new pClass().init(1,true, "java", "7087", "", "user_credit_schedule", "QG", "user_credit_schedule.log", "application.properties", " /dev/null 2>&1 &", null, 2, "用户升级-server", "","mvn clean package     -Ptest -Dmaven.test.skip=true",    "");
// ui----
new pClass().init(1,true, "ui", "7032", "op", "op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "运营系统-ui", "", "", "");
new pClass().init(1,true, "ui", "7040", "", "activity-ui", "QG", null, "src/app/config.js", "npm run qa", "node7", 1, "活动中心-ui", "", "", "");
new pClass().init(1,true, "ui", "7011", "financial", "financial-system-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "财务系统-ui", "", "", "");
new pClass().init(1,true, "ui", "7030", "", "gyxd-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "广源小贷-ui", "", "");
new pClass().init(1,true, "ui", "7008", "off", "offline-ui", "QG", null, "src/app/config/env.config.js", "npm run build", "node7", 1, "线下白条-ui", "", "", "");
new pClass().init(1,true, "ui", "7035", "", "funding-corp-op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "白条债转系统-ui", "", "", "");
new pClass().init(false, "ui", "7007", "pay", "paycenter-ui", false, "QG", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "支付中心-ui", "", "", "");
new pClass().init(1,true, "ui", "7043", "passport", "xyqb-user-ui", "head_group", null, "src/app/config.js", "npm run qa", "node7", 1, "用户注册登录-V2-ui", "", "", "");
new pClass().init(1,true, "ui", "7043", "", "new-xyqb-user-ui", "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "新用户注册登录-V2-ui", "", "", "");
new pClass().init(1,true, "ui", "7039", "merchant", "merchant-op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "商户系统-ui", "", "", "");
new pClass().init(1,true, "ui", "7004", "r", "di-ting-ui", "QG", null, "client/app/config.js", "grunt build", "node7", 1, "信审-ui", "", "", "");
new pClass().init(1,true, "ui", "7020", "sc", "spider-center-ui", "QG", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "授信中心-ui", "", "", "");
new pClass().init(1,true, "ui", "7050", "bt", "bt-ui", "QG", null, "src/app/config/env.config.js", "npm --registry http://172.16.3.15:4873 run qa", "node7", 1, "新版白条-ui", "", "", "");
new pClass().init(1,true, "ui", "7058", "", "mall-ui", "ui", null, "src/app/config/env.config.js", "npm run build", "node7", 1, "商城-ui", "", "", "");
new pClass().init(1,true, "ui", "7001", "m", "xyqb-ui", "QG", null, "client/app/config.js", "grunt build", "node7", 1, "现金贷和白条-现金贷-ui", "", "", "");
new pClass().init(1,true, "ui", "7046", "", "activity-op-ui", "QG", null, "src/config/env.config.js", "npm run build", "node7", 1, "优惠券管理后台-ui", "", "", "");
new pClass().init(1,true, "ui", "7048", "", "order-op-ui", "OP", null, "src/js/env.config.js", "gulp build", "node7", 1, "订单系统-ui", "", "", "");
// new pClass().init(false, "ui", "7002", "", "qgbc-ui", false, "QG", null, "src/app/config/env.config.js", "npm run build_production", "node7", 1, "白条-ui", "", "", "");
new pClass().init(1,true, "ui", "7057", "", "xjd-ui", "QG", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "新版现金贷-ui", "", "", "");
new pClass().init(1,true, "ui", "7007", "", "new-paycenter-ui", "QG", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "新版支付中心-ui", "", "", "");
new pClass().init(1,false, "ui", "7061", "", "wind-control-op-ui", "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "临时项目，未来删除风控平台-ui", "", "", "");
new pClass().init(1,false, "ui", "7016", "", "flow-op-ui", "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "导流UI页面", "", "", "");
new pClass().init(1,false, "ui", "7051", "", "h5-ui", "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "h5平台业务", "李长城", "", "");
new pClass().init(1,true, "ui", "7057", "h5.auth", "ka-spider-center-ui", "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "新版授信UI", "郑少文", "", "");
new pClass().init(1,true, "ui", "7067", "", "new-op-ui", "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "运营系统 vue", "孙小英", "", "");
new pClass().init(1,true, "ui", "7070", "", "customer-op-ui", "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "外部查询-ui", "", "", "");
new pClass().init(1,true, "ui", "7075", "", "business-op-ui", "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "商城结算系统-ui", "王丽英", "", "");
new pClass().init(1,true, "ui", "7077", "", "cuishou-ui-new", "data", null, "src/Config/config.jsx", "npm run dist", "node7", 1, "催收系统-ui", "李斌", "", "");
new pClass().init(1,true, "ui", "7078", "", "ka-factory-ui", "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "KA工厂-ui", "张振武", "", "");
new pClass().init(1,true, "ui", "7080", "", "new-mall-ui", "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "微信商城-ui", "郑少文，周珊", "", "");
// node
new pClass().init(1,true, "node", "7018", "", "AppBackend", "QG", null, "config/environment/test.js", "forever start -a -s --uid AppBackend bin/www", null, 1, "APP后台服务-server", "", "forever stop AppBackend", "");
new pClass().init(1,true, "node", "7041", "", "activity-op", "QG", null, "src/dev.config.js", "sh start.sh", null, 1, "优惠券中心-server", "", "sh stop.sh", "");
new pClass().init(1,true, "node", "7047", "opapi", "op-api", "OP", null, "src/dev.config.js", "sh start.sh", null, 1, "系统Api-Gateway-server", "", "sh stop.sh", "");
new pClass().init(1,true, "node", "7049", "", "fe-api", "QG", null, "src/config.js", "sh start.sh", null, 1, "科传项目-消息推送", "", "pm2 stop fe-api", "");
new pClass().init(1,true, "node", "7054", "", "xyqb-h5-backend", "QG", null, "src/dev.config.js", "sh start.sh", null, 1, "信用钱包帮助中心", "", "sh stop.sh", "");
new pClass().init(1,true, "node", "7055", "", "statistics", "OP", null, "src/config.js", "sh start.sh", null, 1, "收集前端日志", "", "sh stop.sh", "");
new pClass().init(1,true, "node", "7086", "", "message-center-op", "ui", null, "config/env/test.js", "sh start.sh", null, 1, "处理营销时消息处理与发送", "", "sh stop.sh", "");
new pClass().init(1,true, "node", "7073", "","statistics-api", "ui", null, "src/dev.config.js", "sh start.sh", null, 1, "数据可视化-server", "","sh stop.sh","");

//python
new pClass().init(1,true, "python", "7022", "guard", "qin-qiong", "QG", null, "config/beta/config.properties", null, null, 1, "加密解密-server", "", "", "");
new pClass().init(1,true, "python", "7033", "query", "xyqb-query", "QG", null, "server/config/beta/config.ini", null, null, 1, "query-server", "", "", "");
// new pClass().init(false, "python", "7027", "", "msg-center", false, "QG", null, "server/config/beta/config.ini", null, null, 1, "短信中心-以前的sms-center", "", "", "");

var temp = "";

process.argv.forEach(function(val, index, array) {
	if (index >= 2) {
		if (index % 2 == 0) {
			temp = val.replace(/\-/, "");
			param[temp] = "";
		} else {
			param[temp] = val;
		}
	}
});

function getListAttr(projects, attr) {
	var list = [];
	for (var i = 0; i < projects.length; i++) {
		if (projects[i].is_active) {
			list.push(projects[i][attr])
		}
	}
	return list.join(" ");
}
var configFunction = function() {};
configFunction.prototype = {
	getProjectAttr: function(pName, pAttr) {
		if (typeof projects[pName] == "undefined") {
			console.log("")
		} else {
				var attrs = pAttr.split("/");
				if (attrs.length == 0) {
					console.log("")
					return
				}
				var list = [];
				for (var j = 0; j < attrs.length; j++) {
					if(projects[pName][attrs[j]]){
						
						list.push(projects[pName][attrs[j]].split(" ").join("^"));
					}else{
						list.push(" ");
					}
				}
				console.log(list.join("|"))
		}
	},
	getProjectsAttrs: function(projects, attr, attr2) {
		var attrs = attr.split("/");
		if (attrs.length == 0) {
			return
		}
		var list = [];
		//attr2 专有参数，用来表示是否要取带有对外域名的服务
		if(attr2 == "true"){
			for (var i = 0; i < projects.length; i++) {
				if(projects[i].url != ""){
					var li = [projects[i]["name"]];
					for (var j = 0; j < attrs.length; j++) {
						li.push(projects[i][attrs[j]]);
					}
					// li.push(projects[i].url);
					list.push(li.join("|"));
				}
			}
		}else{
			for (var i = 0; i < projects.length; i++) {
				if (projects[i].is_active){
					var li = [projects[i]["name"]];
					for (var j = 0; j < attrs.length; j++) {
						li.push(projects[i][attrs[j]]);
					}
					list.push(li.join("|"));
				}
			}
		}
		return list.join(" ");
	},
	getProjectsAttr: function(type, attr) {
		switch (type) {
			case "java":
				console.log(getListAttr(java_projects, attr));
				break;
			case "ui":
				console.log(getListAttr(ui_projects, attr));
				break;
			case "python":
				console.log(getListAttr(python_projects, attr));
				break;
			case "node":
				console.log(getListAttr(node_projects, attr));
				break;
		}
	}
}

//tower add
module.exports={
	java : java_projects,
	node : node_projects,
	python : python_projects,
	ui : ui_projects
}

var F = new configFunction();

if (param["type"] == "") {
	F.getProjectAttr(param["name"], param["attr"]);
} else if (param["type"] == "multi") {
	var str = "";
	str += F.getProjectsAttrs(java_projects, param["attr"], param["attr2"]);
	str += " " + F.getProjectsAttrs(ui_projects, param["attr"], param["attr2"]);
	str += " " + F.getProjectsAttrs(python_projects, param["attr"], param["attr2"]);
	str += " " + F.getProjectsAttrs(node_projects, param["attr"], param["attr2"]);
	console.log(str)
} else {
	F.getProjectsAttr(param["type"], param["attr"]);
}
