package sgc.portal.com.com.service;

import sgc.portal.base.exception.UnsupportedGirdStatusException;
import sgc.portal.base.util.EasyHashMap;
import sgc.portal.base.websquare.GridRowStatus;
import sgc.portal.com.com.model.TaxOffice;
import sgc.portal.com.com.persistence.ComTaxOfficeMngMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 *
 *
 * .
 *
 * @author KyungHee Jang(khjang@sgc.co.kr)
 * @version 1.0.0
 * @since  2020. 8. 2.
 */

@Transactional
@Service
public class ComTaxOfficeMngService {

    @Autowired
    private ComTaxOfficeMngMapper comTaxOfficeMngMapper;

    /**
	 *
	 *
	 * @param
	 * @
	 *
	 */

    //조회
    public  List<EasyHashMap<String, Object>>  selectComTaxOfficeMng(TaxOffice txofs)
    {
	    return comTaxOfficeMngMapper.selectComTaxOfficeMng(txofs);
    }

	//등록, 수정, 삭제
    public void saveComTaxOfficeMng(List<TaxOffice> txofs) {

	    if (CollectionUtils.isNotEmpty(txofs)) {
	        for (TaxOffice txof : txofs) {
	            switch (txof.getRowStatus()) {
                case GridRowStatus.CREATED:
                    comTaxOfficeMngMapper.insertComTaxOfficeMng(txof);
                    break;
                case GridRowStatus.UPDATED:
                    comTaxOfficeMngMapper.updateComTaxOfficeMng(txof);
                    break;
                case GridRowStatus.DELETED:
                    comTaxOfficeMngMapper.deleteComTaxOfficeMng(txof);
                    break;
                default:
                    throw new UnsupportedGirdStatusException();
	            }
            }
        }
    }
}
