package com.seer.teach.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.user.entity.LevelEntity;
import com.seer.teach.user.entity.UserEntity;
import com.seer.teach.user.mapper.LevelMapper;
import com.seer.teach.user.service.ILevelService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Captain
 * @since 2025-06-18
 */
@Service
@RequiredArgsConstructor
public class ILevelServiceImpl extends ServiceImpl<LevelMapper, LevelEntity> implements ILevelService {

    @Override
    public List<LevelEntity> getListByLevelIds(Set<Integer> levelIds) {
        return super.list(new LambdaQueryWrapper<LevelEntity>().in(LevelEntity::getId, levelIds));
    }

    @Override
    public LevelEntity getDefaultLevel() {
        return this.lambdaQuery()
                .orderByAsc(LevelEntity::getSort)
                .last("LIMIT 1")
                .one();
    }
}
