package com.persagy.functions.weather.business.v2020.maintain;

import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.persagy.core.service.BaseBusinessService;
import com.persagy.core.service.BusinessService;
import com.persagy.framework.util.ConfigUtil;

@Service("ConfigShow")
@SuppressWarnings({"unchecked","rawtypes" })
public class ConfigShow extends BaseBusinessService<Map> implements BusinessService {
	@Override
	public void handle(Map dto, List content) throws Exception {
		String method = (String) dto.get("method");
		List<String> paramList = (List)dto.get("paramList");
		
		if(method == null) {
			throw new Exception("method不能为空！");
		}
		
		Method m = null;
		Object result = null;
		try {
			if(paramList != null) {
				int paramNum = paramList.size();
				if(paramNum > 0) {
					Class[] clzAray = new Class[paramNum];
					String[] paramValue = new String[paramNum];
					for (int i = 0; i < paramNum; i++) {
						clzAray[i] = String.class;
						paramValue[i] = paramList.get(i);
					}
					m = ConfigUtil.class.getMethod(method, clzAray);
					result = m.invoke(new ConfigUtil(), paramValue);
				}
			}else {
				m = ConfigUtil.class.getMethod(method);
				result = m.invoke(new ConfigUtil());
			}
		}catch (Exception e) {
			result = "Error! " + e.getMessage();
		}
		
		content.add(result);
	}
}
