package com.style24.core.biz.service;

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

import com.style24.core.biz.dao.TscClauseDao;
import com.style24.persistence.domain.Clause;

import lombok.extern.slf4j.Slf4j;

import java.util.Collection;

/**
 * 약관 Service
 * 
 * @author gagamel
 * @since 2020. 10. 29
 */
@Service
@Slf4j
public class TscClauseService {

	@Autowired
	private TscClauseDao clauseDao;

	/**
	 * 약관 조회
	 * @param siteCd - 사이트코드
	 * @param clauseType - 약관유형
	 * @return
	 * @author gagamel
	 * @since 2020. 10. 29
	 */
//	@Cacheable(value = "common", key = "'clause-'.concat(#clauseType)")
	public String getClause(String siteCd, String clauseType) {
		Clause clause = new Clause();
		clause.setSiteCd(siteCd);
		clause.setClauseType(clauseType);
		return clauseDao.getClause(clause);
	}

	/**
	 * 약관목록
	 * @param  siteCd - 사이트코드
	 * @param  clauseType - 약관타입
	 * @return Collection<Clause> - 약관목록
	 * @author jsshin
	 * @since 2021. 06. 10
	 */
	public Collection<Clause> getClauseList(String siteCd, String clauseType) {
		Clause clause = new Clause();
		clause.setSiteCd(siteCd);
		clause.setClauseType(clauseType);
		return clauseDao.getClauseList(clause);
	}

	/**
	 * 개인정보취급방침 정보
	 * @param  clauseSq - 약관시퀀스
	 * @return String - 약관내용
	 * @author jsshin
	 * @since 2021. 06. 10
	 */
	public Clause getPrivacyPolicyInfo(Integer clauseSq) {
		return clauseDao.getClauseInfo(clauseSq);
	}


}
