package sgc.portal.cw.cw0402.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.cw0402.dto.CW04020001USearch;
import sgc.portal.cw.cw0402.model.CW04020001U;
import sgc.portal.cw.cw0402.persistence.CW04020001UMapper;

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

@Service
public class CW04020001UService {
    private final CW04020001UMapper mapper;

    public CW04020001UService(CW04020001UMapper mapper) {
        this.mapper = mapper;
    }
    
    //협회 등급.자격 등록관리
    public List<EasyHashMap<String, Object>> selectZehrCareerAssoGradeList(CW04020001USearch search) {
        return mapper.selectZehrCareerAssoGradeList(search);
    }
    
    //인사 경력 조회
    public List<EasyHashMap<String, Object>> selectZehrPhmLicenseIuList(CW04020001USearch search) {
        return mapper.selectZehrPhmLicenseIuList(search);
    }
    
    //협회 등급.자격 등록관리 등록 변경 삭제
    @Transactional
    public Map<String, String> saveZehrCareerAssoGrade (List<CW04020001U> CW04020001U) {
    	
    	Map<String,String> result = new HashMap<>();

        for (CW04020001U cW04020001U : CW04020001U) {
        	
            switch (cW04020001U.getRowStatus()) {
            
                case GridRowStatus.CREATED:
                	mapper.insertZehrCareerAssoGrade(cW04020001U);
                    break;
                    
                case GridRowStatus.UPDATED:
                	mapper.updateZehrCareerAssoGrade(cW04020001U);
                    break;
                    
                case GridRowStatus.DELETED:
                	mapper.deleteZehrCareerAssoGrade(cW04020001U);
                    break;
                default:
                    break;
            }
        }
        return result;
    }
}

