package com.td.WaDa.game.complayersattri.service;

import com.td.WaDa.common.service.*;
import com.td.WaDa.game.complayersattri.pojo.ComPlayersAttri;
import com.td.WaDa.game.complayersattri.vo.ComPlayersAttriVo;
import com.td.WaDa.game.complayersattri.repository.ComPlayersAttriRepository;
import com.td.WaDa.util.CopyUtil;
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;

@Service
@Transactional
public class ComPlayersAttriServiceImpl extends CommonServiceImpl<ComPlayersAttriVo, ComPlayersAttri, Integer> implements ComPlayersAttriService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ComPlayersAttriRepository comPlayersAttriRepository;

    @Override
    public ComPlayersAttriVo findByUserId(String userId) {
        ComPlayersAttri comPlayersAttri = comPlayersAttriRepository.findByUserId(userId).orElse(null);
        return comPlayersAttri == null?null:CopyUtil.copy(comPlayersAttri,ComPlayersAttriVo.class);
    }
}
