package com.eactive.eai.rms.bat.extransinfo;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.eactive.eai.rms.common.base.BaseService;

@Service("exTransInfoService")
public class ExTransInfoService extends BaseService {
 
	@Autowired
	@Qualifier("exTransInfoDao")
	private ExTransInfoDao dao;

	public List<Map<String, Object>> selectList(HashMap<String,Object> paramap) throws Exception {
		
		return dao.selectList(paramap);

	}	
	
	public Integer selectListCount(HashMap<String,Object> paramap) throws Exception {
		 
		return dao.selectListCount(paramap);

	}
	
	public void insert(HashMap<String, Object> paramMap) throws Exception {
		
		dao.insert(paramMap);
	}

	public void update(HashMap<String, Object> paramMap) throws Exception {
		
		dao.update(paramMap);
	}	

	public void delete(HashMap<String, Object> paramMap) throws Exception {
		
		dao.delete(paramMap);
	}
	
	public String checkFieldLength(HashMap<String,Object> paramap) throws Exception 
	{
		String result = "";
		for (ExTransInfoField field : ExTransInfoField.values()) 
		{
			if (!field.getFieldType().toUpperCase().equals("STRING")) continue;
			if (paramap.get(field.name()) == null) {
				result = "request column validation fail - [" + field.name() + "] column is not exist";
				break;
			}
			if (paramap.get(field.name()).toString().length() > field.getFieldLength()) {
				result = "fail - [" + field.name() + "] column length can't over than "+field.getFieldLength();
				break;
			}
		}
		return result;
	}
}