package com.jasamedika.medifirst2000.service.impl;

import com.jasamedika.medifirst2000.dao.ProdukDao;
import com.jasamedika.medifirst2000.dao.ProdukPaketDao;
import com.jasamedika.medifirst2000.dto.ProdukPaketDto;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.entities.ProdukPaket;
import com.jasamedika.medifirst2000.service.ProdukPaketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 14/11/2024
 */
@Service
@Transactional
public class ProdukPaketServiceImpl implements ProdukPaketService {

	@Autowired
	private ProdukPaketDao produkPaketDao;

	@Autowired
	private ProdukDao produkDao;

	@Override
	public void save(ProdukPaketDto dto) {
		Produk paket = produkDao.findByIdProduk(dto.getProduk().getId());
		ProdukPaket produkPaket = ProdukPaket.builder().produk(paket).tipePaket(dto.getTipePaket()).build();
		produkPaket.setStatusEnabled(true);
		produkPaket.setKdProfile((short) 0);
		produkPaketDao.save(produkPaket);
	}

}
