package sgc.portal.co.co0106.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.co.co0106.dto.CO01060001USearch;
import sgc.portal.co.co0106.model.CO01060001U;
import sgc.portal.co.co0106.persistence.CO01060001UMapper;

@Service
public class CO01060001UService {
    private final CO01060001UMapper mapper;

    public CO01060001UService(CO01060001UMapper mapper) {
        this.mapper = mapper;
    }

    public List<EasyHashMap<String, Object>> getList(CO01060001USearch search) {
        return mapper.getList(search);
    }
    
    @Transactional
    public Map<String, String> save(List<CO01060001U> CO01060001U) {
    	
    	Map<String,String> result = new HashMap<>();
    	
    	for (CO01060001U cO01060001U : CO01060001U) {
            switch (cO01060001U.getRowStatus()) {
                case GridRowStatus.CREATED:
                    //mapper.insert(cO01060001U);
                    break;
                case GridRowStatus.UPDATED:
                	mapper.update1(cO01060001U);
                	mapper.update2(cO01060001U);
                    break;
                case GridRowStatus.DELETED:
                    //mapper.delete(cO01060001U);
                    break;
                default:
                    break;
            }
        }
    	return result;
    }
}
