package com.ruoyi.abuwx.service.impl.exam;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.abuwx.mapper.exam.ExmQuestionOptionMapper;
import com.ruoyi.abuwx.domain.exam.ExmQuestionOption;
import com.ruoyi.abuwx.service.exam.IExmQuestionOptionService;

/**
 * 试题选项Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-17
 */
@Service
public class ExmQuestionOptionServiceImpl implements IExmQuestionOptionService 
{
    @Autowired
    private ExmQuestionOptionMapper exmQuestionOptionMapper;

    /**
     * 查询试题选项
     * 
     * @param id 试题选项主键
     * @return 试题选项
     */
    @Override
    public ExmQuestionOption selectExmQuestionOptionById(Long id)
    {
        return exmQuestionOptionMapper.selectExmQuestionOptionById(id);
    }

    /**
     * 查询试题选项列表
     * 
     * @param exmQuestionOption 试题选项
     * @return 试题选项
     */
    @Override
    public List<ExmQuestionOption> selectExmQuestionOptionList(ExmQuestionOption exmQuestionOption)
    {
        return exmQuestionOptionMapper.selectExmQuestionOptionList(exmQuestionOption);
    }

    /**
     * 新增试题选项
     * 
     * @param exmQuestionOption 试题选项
     * @return 结果
     */
    @Override
    public int insertExmQuestionOption(ExmQuestionOption exmQuestionOption)
    {
        return exmQuestionOptionMapper.insertExmQuestionOption(exmQuestionOption);
    }

    /**
     * 修改试题选项
     * 
     * @param exmQuestionOption 试题选项
     * @return 结果
     */
    @Override
    public int updateExmQuestionOption(ExmQuestionOption exmQuestionOption)
    {
        return exmQuestionOptionMapper.updateExmQuestionOption(exmQuestionOption);
    }

    /**
     * 批量删除试题选项
     * 
     * @param ids 需要删除的试题选项主键
     * @return 结果
     */
    @Override
    public int deleteExmQuestionOptionByIds(Long[] ids)
    {
        return exmQuestionOptionMapper.deleteExmQuestionOptionByIds(ids);
    }

    /**
     * 删除试题选项信息
     * 
     * @param id 试题选项主键
     * @return 结果
     */
    @Override
    public int deleteExmQuestionOptionById(Long id)
    {
        return exmQuestionOptionMapper.deleteExmQuestionOptionById(id);
    }

    @Override
    public List<ExmQuestionOption> getList(Long questionId) {
        if(StringUtils.isNull(questionId)){
            return new ArrayList<>();
        }
        ExmQuestionOption exmQuestionOption = new ExmQuestionOption();
        exmQuestionOption.setQuestionId(questionId);
        return exmQuestionOptionMapper.selectExmQuestionOptionList(exmQuestionOption);
    }
}
