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.ExmQuestionAnswerMapper;
import com.ruoyi.abuwx.domain.exam.ExmQuestionAnswer;
import com.ruoyi.abuwx.service.exam.IExmQuestionAnswerService;

/**
 * 试题答案Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-17
 */
@Service
public class ExmQuestionAnswerServiceImpl implements IExmQuestionAnswerService 
{
    @Autowired
    private ExmQuestionAnswerMapper exmQuestionAnswerMapper;

    /**
     * 查询试题答案
     * 
     * @param id 试题答案主键
     * @return 试题答案
     */
    @Override
    public ExmQuestionAnswer selectExmQuestionAnswerById(Long id)
    {
        return exmQuestionAnswerMapper.selectExmQuestionAnswerById(id);
    }

    /**
     * 查询试题答案列表
     * 
     * @param exmQuestionAnswer 试题答案
     * @return 试题答案
     */
    @Override
    public List<ExmQuestionAnswer> selectExmQuestionAnswerList(ExmQuestionAnswer exmQuestionAnswer)
    {
        return exmQuestionAnswerMapper.selectExmQuestionAnswerList(exmQuestionAnswer);
    }

    /**
     * 新增试题答案
     * 
     * @param exmQuestionAnswer 试题答案
     * @return 结果
     */
    @Override
    public int insertExmQuestionAnswer(ExmQuestionAnswer exmQuestionAnswer)
    {
        return exmQuestionAnswerMapper.insertExmQuestionAnswer(exmQuestionAnswer);
    }

    /**
     * 修改试题答案
     * 
     * @param exmQuestionAnswer 试题答案
     * @return 结果
     */
    @Override
    public int updateExmQuestionAnswer(ExmQuestionAnswer exmQuestionAnswer)
    {
        return exmQuestionAnswerMapper.updateExmQuestionAnswer(exmQuestionAnswer);
    }

    /**
     * 批量删除试题答案
     * 
     * @param ids 需要删除的试题答案主键
     * @return 结果
     */
    @Override
    public int deleteExmQuestionAnswerByIds(Long[] ids)
    {
        return exmQuestionAnswerMapper.deleteExmQuestionAnswerByIds(ids);
    }

    /**
     * 删除试题答案信息
     * 
     * @param id 试题答案主键
     * @return 结果
     */
    @Override
    public int deleteExmQuestionAnswerById(Long id)
    {
        return exmQuestionAnswerMapper.deleteExmQuestionAnswerById(id);
    }

    @Override
    public List<ExmQuestionAnswer> getList(Long questionId) {
        if(StringUtils.isNull(questionId)){
            return new ArrayList<>();
        }
        ExmQuestionAnswer questionAnswer = new ExmQuestionAnswer();
        questionAnswer.setQuestionId(questionId);
        return exmQuestionAnswerMapper.selectExmQuestionAnswerList(questionAnswer);
    }
}
