package cokr.xit.fims.payer.service.bean;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cokr.xit.fims.payer.Payer;
import cokr.xit.fims.payer.PayerQuery;
import cokr.xit.fims.payer.service.PayerService;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.lvis.v2406.LvisA01;

/**납부자 대장 서비스 구현체.
 *
 * <p>상세 설명:
 *
 * <pre>
 * ============ 변경 이력 ============
 * 2023-08-18	mjkhan 최초 작성
 * ================================
 * </pre>
 */
@Service("payerService")
public class PayerServiceBean extends AbstractServiceBean implements PayerService {

	/** 납부자 대장 정보 Bean */
	@Resource(name = "payerBean")
	private PayerBean payerBean;

	@Override
	public List<DataObject> getPayerList(PayerQuery req) {
		return payerBean.getPayerList(req);
	}

	@Override
	public List<Payer> getPayers(PayerQuery req) {
		return payerBean.getPayers(req);
	}

	@Override
	public boolean create(Payer payer) {
		return payerBean.create(payer);
	}

	@Override
	public boolean update(Payer payer) {
		return payerBean.update(payer);
	}

	@Override
	public boolean createPayerAddr(Payer payer) {
		return payerBean.createPayerAddr(payer);
	}

	@Override
	public boolean updatePayerAddr(Payer payer) {
		return payerBean.updatePayerAddr(payer);
	}
	@Override
	public Payer findVehicleOwner(LvisA01.A01Request req) {
		return payerBean.getVehicleOwner(req);
	}
/*
	@Override
	public Payer findVehicleOwner(BasicInfoRequest req) {
		List<Payer> payers = payerBean.getVehicleOwners(List.of(req));
		return !payers.isEmpty() ? payers.get(0) : null;
	}

	@Override
	public Payer findVehicleOwner(BasicInfoExtRequest req) {
		return payerBean.getVehicleOwner(req);
	}
*/
	@Override
	public DataObject getCrdnPayerInfo(PayerQuery req) {
		if (req.getCallPurpose() == null) {
			req.setCallPurpose("view");
		}

		if (req.getCallPurpose().equals("create")) {
			return payerBean.getCrdnInfo(req);
		} else {
			return payerBean.getCrdnPayerInfo(req);
		}
	}

	@Override
	public String createCrdnPayer(Payer payer) {
		return payerBean.createCrdnPayer(payer);
	}

	@Override
	public List<DataObject> getPayerHstrys(PayerQuery req) {
		return payerBean.getPayerHstrys(req);
	}

	@Override
	public List<DataObject> getPayerAddrHstrys(PayerQuery req) {
		return payerBean.getPayerAddrHstrys(req);
	}

	@Override
    public DataObject getLastPayerAddrInfo(PayerQuery req) {
        return payerBean.getLastPayerAddrInfo(req);
    }

}