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

import com.td.boss.common.service.*;
import com.td.boss.game.complayersattri.pojo.ComPlayersAttri;
import com.td.boss.game.complayersattri.vo.ComPlayersAttriVo;
import com.td.boss.game.complayersattri.repository.ComPlayersAttriRepository;
import com.td.boss.util.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

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);
    }
}
