package sgc.portal.cw.cw0403.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.cw0403.dto.CW04030001USearch;
import sgc.portal.cw.cw0403.model.CW04030001U;
import sgc.portal.cw.cw0403.persistence.CW04030001UMapper;

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

@Service
public class CW04030001UService {
    private final CW04030001UMapper mapper;

    public CW04030001UService(CW04030001UMapper mapper) {
        this.mapper = mapper;
    }
    
    //협회 경력 등록관리 조회
    public List<EasyHashMap<String, Object>> selectZehrCareerPjtList(CW04030001USearch search) {
        return mapper.selectZehrCareerPjtList(search);
    }
    
    //협회 경력 등록 변경 삭제
    @Transactional
    public Map<String, String> saveZehrCareerPjt (List<CW04030001U> CW04030001U) {
    	
    	Map<String,String> result = new HashMap<>();

        for (CW04030001U cW04030001U : CW04030001U) {
        	
            switch (cW04030001U.getRowStatus()) {
            
                case GridRowStatus.CREATED:
                	mapper.insertZehrCareerPjt(cW04030001U);
                    break;
                    
                case GridRowStatus.UPDATED:
                	mapper.updateZehrCareerPjt(cW04030001U);
                    break;
                    
                case GridRowStatus.DELETED:
                	mapper.deleteZehrCareerPjt(cW04030001U);
                    break;
                default:
                    break;
            }
        }
        return result;
    }
}

