package com.zd.exam.service.impl;

import java.util.List;

import com.zd.common.core.exception.ServiceException;
import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.security.utils.SaveUtil;

import com.zd.exam.domain.ElExam;
import com.zd.exam.service.ElQuService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.exam.mapper.ElExamQuMapper;
import com.zd.exam.domain.ElExamQu;
import com.zd.exam.service.IElExamQuService;

/**
 * 考试自选考题Service业务层处理
 *
 * @author liubo
 * @date 2021-12-13
 */
@Service
public class ElExamQuServiceImpl implements IElExamQuService {
    @Autowired
    private ElExamQuMapper elExamQuMapper;
    @Autowired
    private ElQuService quService;

    /**
     * 查询考试自选考题
     *
     * @param id 考试自选考题主键
     * @return 考试自选考题
     */
    @Override
    public ElExamQu selectElExamQuById(Long id) {
        return elExamQuMapper.selectElExamQuById(id);
    }

    /**
     * 查询考试自选考题列表
     *
     * @param elExamQu 考试自选考题
     * @return 考试自选考题
     */
    @Override
    public List<ElExamQu> selectElExamQuList(ElExamQu elExamQu) {
        return elExamQuMapper.selectElExamQuList(elExamQu);
    }

    /**
     * 新增考试自选考题
     *
     * @param elExamQu 考试自选考题
     * @return 结果
     */
    @Override
    public int insertElExamQu(ElExamQu elExamQu) {
        //设置其他公共字段
        SaveUtil.setCommonAttr(elExamQu);
        return elExamQuMapper.insertElExamQu(elExamQu);
    }

    /**
     * 修改考试自选考题
     *
     * @param elExamQu 考试自选考题
     * @return 结果
     */
    @Override
    public int updateElExamQu(ElExamQu elExamQu) {
        elExamQu.setUpdateTime(DateUtils.getNowDate());
        elExamQu.setUpdateBy(SecurityUtils.getUsername());
        return elExamQuMapper.updateElExamQu(elExamQu);
    }

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

    /**
     * 删除考试自选考题信息
     *
     * @param id 考试自选考题主键
     * @return 结果
     */
    @Override
    public int deleteElExamQuById(Long id) {
        return elExamQuMapper.deleteElExamQuById(id);
    }

    /**
     * 查询考试手动组题信息
     */
    @Override
    public List<ElExamQu> queryByExamId(Long examId) {
        return elExamQuMapper.queryByExamId(examId);
    }

}
