package sgc.portal.cw.cw0404.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.cw0404.dto.CW04040001USearch;
import sgc.portal.cw.cw0404.model.CW04040001U;
import sgc.portal.cw.cw0404.persistence.CW04040001UMapper;

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

@Service
public class CW04040001UService {
    private final CW04040001UMapper mapper;

    public CW04040001UService(CW04040001UMapper mapper) {
        this.mapper = mapper;
    }
    
    //이테크 개인직무 등록관리 조회
    public List<EasyHashMap<String, Object>> selectZehrCareerEmpList(CW04040001USearch search) {
        return mapper.selectZehrCareerEmpList(search);
    }
    
    //이테크 개인직무 등록관리 PJT 팝업
    public List<EasyHashMap<String, Object>> selectZehrCareerEmpPjtList(CW04040001USearch search) {
        return mapper.selectZehrCareerEmpPjtList(search);
    }

    //이테크 개인직무 등록관리 등록 변경 삭제
    @Transactional
    public Map<String, String> saveZehrCareerEmp (List<CW04040001U> CW04040001U) {
    	
    	Map<String,String> result = new HashMap<>();

        for (CW04040001U cW04040001U : CW04040001U) {
        	
            switch (cW04040001U.getRowStatus()) {
            
                case GridRowStatus.CREATED:
                	mapper.insertZehrCareerEmp(cW04040001U);
                    break;
                    
                case GridRowStatus.UPDATED:
                	mapper.updateZehrCareerEmp(cW04040001U);
                    break;
                    
                case GridRowStatus.DELETED:
                	mapper.deleteZehrCareerEmp(cW04040001U);
                    break;
                default:
                    break;
            }
        }
        return result;
    }
}

