package com.ruoyi.ie.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.ruoyi.ie.domain.Subject;
import com.ruoyi.ie.mapper.SubjectMapper;
import com.ruoyi.ie.service.ISubjectService;
import com.ruoyi.system.service.ISysConfigService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 科目Service业务层处理
 *
 * @author mingxue
 * @date 2021-06-06
 */
@Service
public class SubjectServiceImpl implements ISubjectService
{
    @Autowired
    private SubjectMapper subjectMapper;

    /**
     * 查询科目
     *
     * @param subjectid 科目ID
     * @return 科目
     */
    @Override
    public Subject selectSubjectById(Long subjectid)
    {
        return subjectMapper.selectSubjectById(subjectid);
    }

    /**
     * 查询科目列表
     *
     * @param subject 科目
     * @return 科目
     */
    @Override
    public List<Subject> selectSubjectList(Subject subject)
    {
        return subjectMapper.selectSubjectList(subject);
    }

    @Override
    public List<Subject> selectSubjectListBack(Subject subject) {
        return subjectMapper.selectSubjectListBack(subject);
    }

    /**
     * 新增科目
     *
     * @param subject 科目
     * @return 结果
     */
    @Override
    public int insertSubject(Subject subject)
    {
        subject.setUpdateTime(new Date());
        return subjectMapper.insertSubject(subject);
    }

    /**
     * 修改科目
     *
     * @param subject 科目
     * @return 结果
     */
    @Override
    public int updateSubject(Subject subject)
    {
        subject.setUpdateTime(new Date());
        return subjectMapper.updateSubject(subject);
    }

    /**
     * 批量删除科目
     *
     * @param subjectids 需要删除的科目ID
     * @return 结果
     */
    @Override
    public int deleteSubjectByIds(Long[] subjectids)
    {
        return subjectMapper.deleteSubjectByIds(subjectids);
    }

    /**
     * 删除科目信息
     *
     * @param subjectid 科目ID
     * @return 结果
     */
    @Override
    public int deleteSubjectById(Long subjectid)
    {
        return subjectMapper.deleteSubjectById(subjectid);
    }

    @Override
    public List<Subject> getQuestionsSubject(Integer phaseId) {
        return subjectMapper.getQuestionsSubject(phaseId);
    }
}
