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

import com.YuyeTech.TPlat.dto.LevelHonorDTO;
import com.YuyeTech.TPlat.game.levelInfo.repository.LevelHonorRepository;
import com.YuyeTech.TPlat.game.levelInfo.service.LevelHonorService;
import com.YuyeTech.TPlat.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;
    }
}
