package sgc.portal.cd.cd0303.service;

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

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

import sgc.portal.base.util.EasyHashMap;
import sgc.portal.cd.cd0301.model.CD03010001P;
import sgc.portal.cd.cd0303.dto.CD03030001USearch;
import sgc.portal.cd.cd0303.persistence.CD03030001UMapper;

@Service
public class CD03030001UService {

	private final CD03030001UMapper mapper;
	
    public CD03030001UService(CD03030001UMapper mapper) {
        this.mapper = mapper;
    }
	
    /**
     * 작업지시서 승인 조회
     * @param search
     * @return
     */
	public List<EasyHashMap<String, Object>> selectConWkiOdrList(CD03030001USearch search) {
		return mapper.selectConWkiOdrList(search);
	}

	/**
	 * 작업지시서 승인 결재 후처리
	 * @param cD03010001P
	 * @return
	 */
    @Transactional
	public Map<String, String> approval(CD03010001P cD03010001P) {
    	Map<String,String> result = new HashMap<>();
    	
    	// SM_COM_APRV.APRV_STUS_CD의 결재상태 조회
    	String aprvStusCd = mapper.selectAprvStusCd(cD03010001P);
    	cD03010001P.setAprvStusCd(aprvStusCd);
    	
    	mapper.approval(cD03010001P);
		return result;
	}

}
