package com.style24.scm.biz.service;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.style24.persistence.domain.CommonCode;
import com.style24.persistence.domain.SupplyCompany;
import com.style24.scm.biz.dao.TssRendererDao;

import lombok.extern.slf4j.Slf4j;

/**
 * 콤보박스, 체크박스, 라디오버튼 구성 시 필요한 Renderer Service
 *
 * @author gagamel
 * @since 2020. 10. 19
 */
@Service
@Slf4j
public class TssRendererService {

	@Autowired
	private TssRendererDao rendererDao;

	/**
	 * 공급업체 목록
	 * @param supplyCompany - 공급업체 정보
	 * @return 공급업체 목록
	 * @author Daehyoung
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getSupplyCompanyList(SupplyCompany supplyCompany) {
		return rendererDao.getSupplyCompanyList(supplyCompany);
	}

	/**
	 * 공급업체 목록
	 * @return 공급업체 목록
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getSupplyCompanyList() {
		return this.getSupplyCompanyList(new SupplyCompany());
	}

	/**
	 * 공급업체 목록
	 * @param supplyCompCd - 공급업체코드
	 * @return 공급업체 목록
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getSupplyCompanyList(String supplyCompCd) {
		SupplyCompany supplyCompany = new SupplyCompany();
		supplyCompany.setSupplyCompCd(supplyCompCd);
		return this.getSupplyCompanyList(supplyCompany);
	}

	/**
	 * 공급업체 목록
	 * @param supplyCompCd - 공급업체코드
	 * @param selfYn - 자사여부
	 * @return 공급업체 목록
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getSupplyCompanyList(String supplyCompCd, String selfYn) {
		SupplyCompany supplyCompany = new SupplyCompany();
		supplyCompany.setSupplyCompCd(supplyCompCd);
		supplyCompany.setSelfYn(selfYn);
		return this.getSupplyCompanyList(supplyCompany);
	}

	/**
	 * 자사공급업체 목록
	 * @return 자사공급업체 목록
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getSelfSupplyCompanyList() {
		SupplyCompany supplyCompany = new SupplyCompany();
		supplyCompany.setSelfYn("Y");
		return this.getSupplyCompanyList(supplyCompany);
	}

	/**
	 * 공통코드 목록 - 어드민 공통코드 캐시 미적용 - 상품등록시 시즌년도 캐쉬로 인한 정보 오류로 수정 2020.06.02
	 * @param commoncode - 공통코드 정보
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
//	@Cacheable(value = "common", key = "'commoncode-'.concat(#commoncode.cdGb)")
	public Collection<CommonCode> getCommonCodeList(CommonCode commoncode) {
		return rendererDao.getCommonCodeList(commoncode);
	}

	/**
	 * 공통코드 목록
	 * @param cdGb - 코드구분
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getCommonCodeList(String cdGb) {
		CommonCode commoncode = new CommonCode();
		commoncode.setCdGb(cdGb);
		return this.getCommonCodeList(commoncode);
	}

	/**
	 * 공통코드 목록
	 * @param grpCodeId - 코드구분
	 * @param useYn     - 사용여부
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getCommonCodeList(String cdGb, String useYn) {
		CommonCode commoncode = new CommonCode();
		commoncode.setCdGb(cdGb);
		commoncode.setUseYn(useYn);
		return this.getCommonCodeList(commoncode);
	}

	/**
	 * 현재 유효한 공통코드 목록
	 * @param cdGb - 코드구분
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getAvailCommonCodeList(String cdGb) {
		return this.getCommonCodeList(cdGb, "Y");
	}

	/**
	 * 공통코드 목록
	 * @param cdGb   -코드구분
	 * @param useYn  - 사용여부
	 * @param cdDesc - 코드설명
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getCommonCodeList(String cdGb, String useYn, String cdDesc) {
		CommonCode commoncode = new CommonCode();
		commoncode.setCdGb(cdGb);
		commoncode.setUseYn(useYn);
		commoncode.setCdDesc(cdDesc);
		return this.getCommonCodeList(commoncode);
	}

	/**
	 * 공통코드 목록
	 * @param cdGb      -코드구분
	 * @param useYn     - 사용여부
	 * @param exceptCds - 제외코드배열
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 7
	 */
	public Collection<CommonCode> getCommonCodeList(String cdGb, String useYn, String[] exceptCds) {
		CommonCode commoncode = new CommonCode();
		commoncode.setCdGb(cdGb);
		commoncode.setUseYn(useYn);
		commoncode.setExceptCds(exceptCds);
		return this.getCommonCodeList(commoncode);
	}

}
