package com.style24.front.biz.service;

import java.util.Collection;

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

import com.style24.front.biz.dao.TsfRendererDao;
import com.style24.persistence.domain.CommonCode;

import lombok.extern.slf4j.Slf4j;

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

	@Autowired
	private TsfRendererDao rendererDao;

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

	/**
	 * 공통코드 목록
	 * @param cdGb - 코드구분
	 * @return
	 * @author gagamel
	 * @since 2021. 1. 29
	 */
	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 2021. 1. 29
	 */
	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 2021. 1. 29
	 */
	public Collection<CommonCode> getAvailCommonCodeList(String cdGb) {
		return this.getCommonCodeList(cdGb, "Y");
	}

	/**
	 * 공통코드 목록
	 * @param cdGb   -코드구분
	 * @param useYn  - 사용여부
	 * @param cdDesc - 코드설명
	 * @return
	 * @author gagamel
	 * @since 2021. 1. 29
	 */
	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 2021. 1. 29
	 */
	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);
	}

	/**
	 * 택배사명 목록 조회
	 * @return CommonCode
	 * @author moon
	 * @since 2020. 11. 05
	 */
	public Collection<CommonCode> getShipCompanyList() {
		CommonCode data = new CommonCode();
		data.setUseYn("Y");
		return rendererDao.getShipCompanyList(data);
	}
}
