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

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.fims.excl.ExclQuery;
import cokr.xit.fims.levy.Levy;
import cokr.xit.fims.levy.LevyQuery;
import cokr.xit.fims.levy.service.Levy01Service;

/**부과 대장 서비스 구현체.
 *
 * <p>상세 설명:
 *
 * <pre>
 * ============ 변경 이력 ============
 * 2023-08-30	JoJH 최초 작성
 * ================================
 * </pre>
 */
@Service("levy01Service")
public class Levy01ServiceBean extends AbstractServiceBean implements Levy01Service {

	/** 부과 대장 정보 Bean */
	@Resource(name = "levy01Bean")
	private Levy01Bean levy01Bean;

	@Override
	public List<DataObject> getLevyList(LevyQuery req) {
		return levy01Bean.getLevyList(req);
	}

	@Override
	public List<DataObject> getLevys(LevyQuery req) {
		return levy01Bean.getLevys(req);
	}

	@Override
	public DataObject getLevyInfo(LevyQuery req) {
		return levy01Bean.getLevyInfo(req);
	}

	@Override
	public boolean createLevy(Levy levy) {
		return levy01Bean.createLevy(levy);
	}

	@Override
	public boolean updateLevy(Levy levy) {
		return levy01Bean.updateLevy(levy);
	}

	@Override
	public boolean removeLevy(Levy levy) {
		return levy01Bean.removeLevy(levy);
	}

	@Override
	public boolean removeLevys(LevyQuery req) {
		// 변수 선언
		boolean retSuccess = false;												// DB 처리 결과

		// 부과 IDs 건수를 확인하여 1건이하면.. 종료
		if (req.getRductIDs().length < 1 ) {
			return retSuccess;
		}

		// 부과 IDs 만큼 반복..
		for (int iLoop = 0; iLoop < req.getRductIDs().length; iLoop++) {
			Levy levy = new Levy();

			levy.setLevyId(req.getLevyIDs()[iLoop]);							// 부과 ID
			levy.setDelRsn(req.getDelRsn());									// 삭제 사유

			// 의견제출 삭제 호출
			retSuccess = levy01Bean.removeLevy(levy);
			if (!retSuccess) {
				return retSuccess;
			}
		}

		return true;
	}

}
