package com.saye.hrs.config;


import com.saye.hrs.model.ServiceParams;
import com.saye.hrs.model.StatusDefine;
import com.saye.hrs.service.system.ServiceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;

@Component
public class LoadStatusDefine implements ApplicationRunner {

	@Autowired
	private ServiceParamsService serviceParamsService;
	
	@Override
	public void run(ApplicationArguments args) throws Exception {
		System.out.println(/************************************开始加载系统默认参数*************************************************/);
		
		/*StatusDefine sd=new StatusDefine();
		List<ServiceParams> paramsList = this.serviceParamsService.selectServiceParams(new HashMap<String, String>());
		
		for (int i = 0; i < paramsList.size(); i++) {
			ServiceParams param = paramsList.get(i);
			
			String paramName = param.getParamCode();
			Field declaredField = null;
			try {
				declaredField = sd.getClass().getDeclaredField(paramName);
			} catch (Exception e) {
				//e.printStackTrace();
			}
			if(declaredField !=null){
				declaredField.setAccessible(true);
				declaredField.set(sd,param.getParamVal());
			}
			
		}*/
		
		System.out.println(/************************************加载系统默认参数完成*************************************************/);
		
	}
	
}
