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

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cokr.xit.base.file.FileInfo;
import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean;
import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.sprt.SprtQuery;
import cokr.xit.fims.sprt.service.Sprt02Service;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;

/**개별 총정보 서비스 구현체.
*
* <p>상세 설명:
*
* <pre>
* ============ 변경 이력 ============
* 2023-08-18	JoJH 최초 작성
* ================================
* </pre>
*/
@Service("sprt02Service")
public class Sprt02ServiceBean extends AbstractServiceBean implements Sprt02Service {

	/** 업무지원 Bean */
	@Resource(name="sprt02Bean")
	protected Sprt02Bean sprt02Bean;

	/** 파일 Bean */
	@Resource(name="fileBean")
	private FileBean fileBean;

	@Override
	public DataObject getCrdnInfo(SprtQuery req) {
		return sprt02Bean.getCrdnInfo(req);
	}

	@Override
	public DataObject getCrdnPayerInfo(SprtQuery req) {
		// 단속, 납부자 조회
		DataObject dataObject = sprt02Bean.getCrdnPayerInfo(req);

		// 단속 파일 조회
		List<DataObject> fileList = getCrdnFileList(req);

		if (fileList != null && !fileList.isEmpty()) {
			dataObject.set("fileList", fileList);
		}

		return dataObject;
	}

	@Override
	public List<DataObject> getCrdnFileList(SprtQuery req) {
		// 첨부 파일 조회
		FileQuery fileQuery = new FileQuery();

		fileQuery.setInfoType(Crdn.INF_TYPE);
		fileQuery.setInfoKeys(req.getCrdnId());

		return fileBean.getFileList(fileQuery);
	}

	@Override
	public String updateCrdnImageFile(Crdn crdn, List<FileInfo> newFileInfoList) {
		return sprt02Bean.updateCrdnImageFile(crdn, newFileInfoList);
	}

	@Override
	public String removeCrdnImageFile(String crdnId, Integer atchFileCnt, String... fileIDs) {
		return sprt02Bean.removeCrdnImageFile(crdnId, atchFileCnt, fileIDs);
	}

}
