package sgc.portal.cw.cw0401.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.cw0401.dto.CW04010001USearch;
import sgc.portal.cw.cw0401.model.CW04010001U;
import sgc.portal.cw.cw0401.persistence.CW04010001UMapper;

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

@Service
public class CW04010001UService {
    private final CW04010001UMapper mapper;

    public CW04010001UService(CW04010001UMapper mapper) {
        this.mapper = mapper;
    }
    
    //협회 경력 등록관리 조회
    public List<EasyHashMap<String, Object>> selectZehrCareerAssoRecordList(CW04010001USearch search) {
        return mapper.selectZehrCareerAssoRecordList(search);
    }
    
  //협회 경력 등록 변경 삭제
    @Transactional
    public Map<String, String> saveZehrCareerAssoRecord (List<CW04010001U> CW04010001U) {
    	
    	Map<String,String> result = new HashMap<>();

        for (CW04010001U cW04010001U : CW04010001U) {
        	
            switch (cW04010001U.getRowStatus()) {
            
                case GridRowStatus.CREATED:
                	mapper.insertZehrCareerAssoRecord(cW04010001U);
                    break;
                    
                case GridRowStatus.UPDATED:
                	mapper.updateZehrCareerAssoRecord(cW04010001U);
                    break;
                    
                case GridRowStatus.DELETED:
                	mapper.deleteZehrCareerAssoRecord(cW04010001U);
                    break;
                default:
                    break;
            }
        }
        return result;
    }
}

