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

import com.YuyeTech.HeartRate.dto.LevelConditionDTO;
import com.YuyeTech.HeartRate.game.levelInfo.repository.LevelConditionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


/**
 * @author:slambb
 * @date:2021/8/7
 */
@Service
public class LevelConditionServiceImpl implements LevelConditionService {

    @Autowired
    private LevelConditionRepository levelConditionRepository;

    @Override
    public List<LevelConditionDTO> findByConditionUnlockIn(String conditionUnlock) {
        return levelConditionRepository.findByTypeAndLimitTypeIn(0,Pattern.compile(",").splitAsStream(conditionUnlock).map((x) -> Integer.parseInt(x))
                .collect(Collectors.toList()));
    }
}
