package sgc.portal.co.co0102.service;

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.co0102.dto.CO01020001USearch;
import sgc.portal.co.co0102.model.CO01020001U;
import sgc.portal.co.co0102.persistence.CO01020001UMapper;

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

@Service
public class CO01020001UService {
    private final CO01020001UMapper mapper;

    public CO01020001UService(CO01020001UMapper mapper) {
        this.mapper = mapper;
    }

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