package sgc.portal.cw.cw0610.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.cw.cw0610.model.CW06100001U;
import sgc.portal.cw.cw0610.dto.CW06100001USearch;
import sgc.portal.cw.cw0610.persistence.CW06100001UMapper;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CW06100001UService {
    private final CW06100001UMapper mapper;

    public CW06100001UService(CW06100001UMapper mapper) {
        this.mapper = mapper;
    }

    public List<EasyHashMap<String, Object>> getList(CW06100001USearch search) {
        return mapper.getList(search);
    }
    
    @Transactional
    public Map<String, String> save(List<CW06100001U> CW06100001U) {
    	
    	Map<String,String> result = new HashMap<>();
    	
    	for (CW06100001U cW06100001U : CW06100001U) {
            switch (cW06100001U.getRowStatus()) {
                case GridRowStatus.UPDATED:
                    update(cW06100001U);
                    break;
                default:
                    break;
            }
        }
    	return result;
    }

    private void update(CW06100001U cW06100001U) {
        mapper.update(cW06100001U);
    }
}
