package jnpf.cultivate.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.cultivate.mapper.FtbCultivateQuestionOptionMapper;
import jnpf.cultivate.service.FtbCultivateQuestionOptionService;
import jnpf.model.cultivate.po.question.FtbCultivateQuestionOption;
import jnpf.model.enums.CourseEnums;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FtbCultivateQuestionOptionServiceImpl extends ServiceImpl<FtbCultivateQuestionOptionMapper, FtbCultivateQuestionOption> implements FtbCultivateQuestionOptionService {

    /**
     * 根据题目id查询题目的选项列表
     * @param questionIds 题目id集合
     * @return
     */
    @Override
    public List<FtbCultivateQuestionOption> queryOptionListByQuestionIds(List<String> questionIds) {
        QueryWrapper<FtbCultivateQuestionOption> wrapper = new QueryWrapper<>();
        wrapper.lambda().in(FtbCultivateQuestionOption::getQuestionId, questionIds)
                .eq(FtbCultivateQuestionOption::getEnabledMark, CourseEnums.EnabledMarkType.VALID.getCode())
                .orderByAsc(FtbCultivateQuestionOption::getSortCode);
        return baseMapper.selectList(wrapper);
    }
}
