package com.style24.front.biz.service;

import java.util.Collection;

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

import com.style24.front.biz.dao.TsfFaqDao;
import com.style24.persistence.domain.Faq;

import lombok.extern.slf4j.Slf4j;

/**
 * FAQ Service
 * 
 * @author gagamel
 * @since 2020. 12. 23
 */
@Service
@Slf4j
public class TsfFaqService {

	@Autowired
	private TsfFaqDao faqDao;

	/**
	 * FAQ 자주 묻는 질문 목록 (10개)
	 * @param siteCd - 사이트코드
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 23
	 */
	public Collection<Faq> getFaqLikesList(String siteCd) {
		return faqDao.getFaqLikesList(siteCd);
	}

	/**
	 * FAQ 총건수
	 * @param faq - FAQ 정보
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 23
	 */
	public int getFaqTotalCount(Faq faq) {
		return faqDao.getFaqTotalCount(faq);
	}

	/**
	 * FAQ 목록
	 * @param faq - FAQ 정보
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 23
	 */
	public Collection<Faq> getFaqList(Faq faq) {
		return faqDao.getFaqList(faq);
	}

	/**
	 * FAQ 조회수 Update
	 * @param faqSq - FAQ일련번호
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 23
	 */
	@Transactional("shopTxnManager")
	public void updateFaqReadCount(Integer faqSq) {
		faqDao.updateFaqReadCount(faqSq);
	}

	/**
	 * FAQ 상세
	 * @param faqSq - FAQ일련번호
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 23
	 */
	public Faq getFaq(Integer faqSq) {
		this.updateFaqReadCount(faqSq);
		return faqDao.getFaq(faqSq);
	}

}
