package sgc.portal.ei.ei0501.service;

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

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sgc.portal.base.util.EasyHashMap;
import sgc.portal.base.websquare.GridRowStatus;
import sgc.portal.ei.ei0101.model.EI01010001U;
import sgc.portal.ei.ei0501.dto.EI05010001USearch;
import sgc.portal.ei.ei0501.model.EI05010001U;

import sgc.portal.ei.ei0501.persistence.EI05010001UMapper;

import lombok.extern.slf4j.Slf4j;


@Slf4j
@Service
public class EI05010001UService {
    private final EI05010001UMapper mapper;

    public EI05010001UService(EI05010001UMapper mapper) {
        this.mapper = mapper;
    }
    
    /*
     * SEARCH LIST
     */
    public List<EasyHashMap<String, Object>> getList(EI05010001USearch search) {
        return mapper.getList(search);
    }
    
    public List<EasyHashMap<String, Object>> getList2(EI05010001USearch search) {
    	return mapper.getList2(search);
    }
    
    
    /*
     * SAVE LIST
     */
    @Transactional
    public Map<String, String> update1(List<EI05010001U> eI05010001U) {
    	Map<String,String> result = new HashMap<>();
    	for (EI05010001U vo : eI05010001U) {
    		update1(vo);
        }
    	
    	return result;
    }
    
    
    /*
     * PROCEDURE EXCUTE
     */
    public Object callMiEng(EI05010001USearch search) {
    	mapper.callSpEisMiRunEng(search);
		return search;
    }
    
    public Object callMiEtec(EI05010001USearch search) {
    	mapper.callSpEisMiRunEtec(search);
		return search;
    }

    
    /*
     * UPDATE
     */
    private void update1(EI05010001U eI05010001U) {
    	mapper.insertOrUpdate1(eI05010001U);
    }
    
}
