package sgc.portal.cd.cd0201.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sgc.portal.base.util.EasyHashMap;
import sgc.portal.cd.cd0201.dto.CD02010001PSearch;
import sgc.portal.cd.cd0201.model.CD02010001P;
import sgc.portal.cd.cd0201.persistence.CD02010001PMapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CD02010001PService {
    private final CD02010001PMapper mapper;

    public CD02010001PService(CD02010001PMapper mapper) {
        this.mapper = mapper;
    }
    
    //CON_DAY_WRK 현장일보
    public List<EasyHashMap<String, Object>> getListConDayWrkCopy(CD02010001PSearch search) {
        return mapper.getListConDayWrkCopy(search);
    }
    
    @Transactional
    public Map<String, String> saveConDayWrkCopy(CD02010001P cD02010001P) {
    	
    	Map<String,String> result = new HashMap<>();
    	
    	mapper.deleteConDayWrk(cD02010001P);
    	mapper.deleteConDayWrkCn(cD02010001P);
    	mapper.deleteConDayWrkMan(cD02010001P);
    	mapper.deleteConDayWrkEq(cD02010001P);
    	mapper.deleteConDayWrkEqprt(cD02010001P);
    	mapper.deleteConDayWrkBd(cD02010001P);
    	mapper.deleteConDayWrkBdprt(cD02010001P);
    	mapper.deleteConDayWrkPr(cD02010001P);
    	mapper.insertConDayWrk(cD02010001P);
    	mapper.insertConDayWrkCn(cD02010001P);
    	mapper.insertConDayWrkMan(cD02010001P);
    	mapper.insertConDayWrkEq(cD02010001P);
    	mapper.insertConDayWrkEqprt(cD02010001P);
    	mapper.insertConDayWrkBd(cD02010001P);
    	mapper.insertConDayWrkBdprt(cD02010001P);
    	mapper.insertConDayWrkPr(cD02010001P);
    	
    	return result;
    }
}
