package sgc.portal.ll.ll0101.service;

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

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sgc.portal.ll.ll0101.dto.LL01010001PSearch;
import sgc.portal.ll.ll0101.model.LL01010001P;
import sgc.portal.ll.ll0101.persistence.LL01010001PMapper;

@Service
public class LL01010001PService {

	private final LL01010001PMapper mapper;
	
    public LL01010001PService(LL01010001PMapper mapper) {
        this.mapper = mapper;
    }
	
    /**
     * 작업지시서 작성(팝업) 조회
     * @param search
     * @return
     */
	public LL01010001P selectLlInfoList(LL01010001PSearch search) {
		LL01010001P LL01010001p = mapper.selectLlInfoList(search);
		return LL01010001p;
	}
    
	/**
	 * 작업지시서 작성(팝업) 저장
	 * @param LL01010001P
	 * @return
	 */
    @Transactional
	public Map<String, String> saveLlInfo(LL01010001P LL01010001P) {
    	Map<String,String> result = new HashMap<>();
    	
    	int seq = LL01010001P.getSeq();
    	
    	if(seq != 0) {
			mapper.updateLlInfo(LL01010001P);
    	}else {//신규일경우
    		seq = mapper.selectSeq(LL01010001P);
    		LL01010001P.setSeq(seq);
    		mapper.insertLlInfo(LL01010001P);
    	}
    	
		return result;
	}

}
