package sgc.portal.base.service;

import sgc.portal.base.model.SmComHelp;
import sgc.portal.base.persistence.ComHelpDeskMapper;
import sgc.portal.base.util.EasyHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * The type Com help desk service.
 *
 * @author mir(khjang @ sgc.co.kr)
 * @version 1.0.0
 * @since 2020. 8. 2.
 */
@Transactional
@Service
public class ComHelpDeskService {

    @Autowired
    private ComHelpDeskMapper comHelpDeskMapper;

    /**
     * Select helpdesk list.
     *
     * @param smComHelp the sm com help
     * @return the list
     */
//공통내역코드 정보 조회
    public List<EasyHashMap<String, Object>> selectHelpdesk(SmComHelp smComHelp) {
        return comHelpDeskMapper.selectHelpdesk(smComHelp);
    }

    /**
     * Save help desk map.
     *
     * @param smComHelp the sm com help
     * @return the map
     */
//인원포인트계획 저장
    public Map<String, String> saveHelpDesk(SmComHelp smComHelp) {
        Map<String,String> result = new HashMap<>();
                if(comHelpDeskMapper.getStatus(smComHelp) == 0){
                    comHelpDeskMapper.insertComHelpDesk(smComHelp);
                }else{
                    comHelpDeskMapper.updateComHelpDesk(smComHelp);
                }
        return result;
    }
}
