package com.YuyeTech.TPlat.service.impl;

import com.YuyeTech.TPlat.dataobject.RankInfo;
import com.YuyeTech.TPlat.repository.RankInfoRepository;
import com.YuyeTech.TPlat.service.RankInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author:slambb
 * @date:2020/3/20
 */
@Service
public class RankInfoServiceImpl implements RankInfoService {

    @Autowired
    private RankInfoRepository rankInfoRepository;

    @Override
    public RankInfo findByGameId(String gameId) {
        return rankInfoRepository.findByRObjectId(gameId).orElse(null);
    }

    @Override
    public RankInfo addRankInfo(RankInfo rankInfo) {
        return rankInfoRepository.save(rankInfo);
    }

    @Override
    public RankInfo findShowRankInfoByUserId(String userId) {
        //获取
        RankInfo rankInfo =  rankInfoRepository.findByUserIdAndRankShow(userId,1).orElse(null);

        if(rankInfo == null){
            return null;
        }

        return rankInfo;
    }
}
