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

import com.td.boss.common.service.*;
import com.td.boss.game.comequipattributes.pojo.ComEquipAttributes;
import com.td.boss.game.comequipattributes.vo.ComEquipAttributesVo;
import com.td.boss.game.comequipattributes.repository.ComEquipAttributesRepository;
import com.td.boss.game.comgeneralattributes.pojo.ComGeneralAttributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

@Service
@Transactional
public class ComEquipAttributesServiceImpl extends CommonServiceImpl<ComEquipAttributesVo, ComEquipAttributes, Integer> implements ComEquipAttributesService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ComEquipAttributesRepository comEquipAttributesRepository;

    @Override
    @Cacheable(value = "comEquipAttributesType",key = "#type")
    public ComEquipAttributes findByType(Integer type) {
        return comEquipAttributesRepository.findByType(type).orElse(null);
    }

    @Override
    @Cacheable(value = "comEquipAttributesAll")
    public List<ComEquipAttributes> findAll() {
        return comEquipAttributesRepository.findAll();
    }
}
