package com.td.boss.game.combossesbattle.service;

import com.td.boss.common.service.*;
import com.td.boss.game.combossesbattle.pojo.ComBossesBattle;
import com.td.boss.game.combossesbattle.vo.ComBossesBattleVo;
import com.td.boss.game.combossesbattle.repository.ComBossesBattleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import java.util.Optional;

@Service
@Transactional
public class ComBossesBattleServiceImpl extends CommonServiceImpl<ComBossesBattleVo, ComBossesBattle, Integer> implements ComBossesBattleService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ComBossesBattleRepository comBossesBattleRepository;

    @Override
    public ComBossesBattle addComBossesBattle(ComBossesBattle comBossesBattle) {
        return comBossesBattleRepository.save(comBossesBattle);
    }

    @Override
    public ComBossesBattle findByPlayerIdAndBossId(Integer playerId,Integer bossId) {
        return comBossesBattleRepository.findByPlayerIdAndBossesId(playerId,bossId).orElse(null);
    }

    @Override
    public List<ComBossesBattle> findAllByBossesId(Integer bossesId) {
        return comBossesBattleRepository.findAllByBossesId(bossesId);
    }
}
