package com.style24.scm.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.persistence.domain.Counsel;
import com.style24.scm.biz.dao.TssCounselDao;
import com.style24.scm.support.security.session.TssSession;

import lombok.extern.slf4j.Slf4j;

/**
 * 상품문의 Service
 *
 * @author gagamel
 * @since 2020. 12. 28
 */
@Service
@Slf4j
public class TssCounselService {

	@Autowired
	private TssCounselDao counselDao;

	/**
	 * 상품문의 목록
	 * @param counsel -상담정보
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 28
	 */
	public Collection<Counsel> getGoodsQnaList(Counsel counsel) {
		counsel.setAnsCompCd(TssSession.getInfo().getSupplyCompCd());
		return counselDao.getGoodsQnaList(counsel);
	}

	/**
	 * 상품문의 상세
	 * @param counselSq - 상담일련번호
	 * @return
	 * @author gagamel
	 * @since 2020. 12. 28
	 */
	public Counsel getGoodsQna(Integer counselSq) {
		Counsel counsel = new Counsel();
		counsel.setCounselSq(counselSq);
		counsel.setAnsCompCd(TssSession.getInfo().getSupplyCompCd());
		return counselDao.getGoodsQna(counsel);
	}

	/**
	 * 상품문의 답변 저장
	 * @param counsel - 상담정보
	 * @author gagamel
	 * @since 2020. 12. 28
	 */
	@Transactional("shopTxnManager")
	public void updateGoodsQnaAnswer(Counsel counsel) {
		counsel.setAnsCompCd(TssSession.getInfo().getSupplyCompCd());
		counselDao.updateGoodsQnaAnswer(counsel);
	}

}
