package com.YuyeTech.HeartRate.game.levelInfo.service;

import com.YuyeTech.HeartRate.dto.LevelHonorDTO;
import com.YuyeTech.HeartRate.game.levelInfo.repository.LevelHonorRepository;
import com.YuyeTech.HeartRate.utils.AliyunOSSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author:slambb
 * @date:2021/8/7
 */
@Service
public class LevelHonorServiceImpl implements LevelHonorService {

    @Autowired
    private LevelHonorRepository levelHonorRepository;

    @Autowired
    private AliyunOSSUtil aliyunOSSUtil;

    @Override
    public LevelHonorDTO findByHonorType(Integer type) {
        LevelHonorDTO levelHonorDTO = levelHonorRepository.findByType(type).orElse(null);
        if (levelHonorDTO != null) {
            levelHonorDTO.setUrl(aliyunOSSUtil.addDomainName(levelHonorDTO.getUrl()));
        }
        return levelHonorDTO;
    }
}
