package com.ruoyi.sy.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.sy.domain.SyMajor;
import com.ruoyi.sy.mapper.SyMajorMapper;
import com.ruoyi.sy.service.ISyMajorService;
import com.ruoyi.util.ConstantUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 专业Service业务层处理
 *
 * @author mingxue
 * @date 2022-04-27
 */
@Service
public class SyMajorServiceImpl implements ISyMajorService
{
    @Autowired
    private SyMajorMapper syMajorMapper;

    /**
     * 查询专业
     *
     * @param id 专业ID
     * @return 专业
     */
    @Override
    public SyMajor selectSyMajorById(Long id)
    {
        return syMajorMapper.selectSyMajorById(id);
    }

    @Override
    public SyMajor selectSyMajorByCode(String code) {
        String examTypeData = ConstantUtil.getExamTypeData(SecurityUtils.getLoginUser().getUser().getExamType());
        return syMajorMapper.selectSyMajorByCode(examTypeData, code);
    }

    @Override
    public List<SyMajor> selectSyMajorByLevel(String examType, Integer level) {
        return syMajorMapper.selectSyMajorByLevel(examType, level);
    }

    /**
     * 查询专业列表
     *
     * @param syMajor 专业
     * @return 专业
     */
    @Override
    public List<SyMajor> selectSyMajorList(SyMajor syMajor)
    {
        return syMajorMapper.selectSyMajorList(syMajor);
    }

    @Override
    public List<SyMajor> selectSyMajorAndChildrenByCode(SyMajor syMajor) {
        return syMajorMapper.selectSyMajorAndChildrenByCode(syMajor);
    }

    /**
     * 新增专业
     *
     * @param syMajor 专业
     * @return 结果
     */
    @Override
    public int insertSyMajor(SyMajor syMajor)
    {
        return syMajorMapper.insertSyMajor(syMajor);
    }

    /**
     * 修改专业
     *
     * @param syMajor 专业
     * @return 结果
     */
    @Override
    public int updateSyMajor(SyMajor syMajor)
    {
        return syMajorMapper.updateSyMajor(syMajor);
    }

    /**
     * 批量删除专业
     *
     * @param ids 需要删除的专业ID
     * @return 结果
     */
    @Override
    public int deleteSyMajorByIds(Long[] ids)
    {
        return syMajorMapper.deleteSyMajorByIds(ids);
    }

    /**
     * 删除专业信息
     *
     * @param id 专业ID
     * @return 结果
     */
    @Override
    public int deleteSyMajorById(Long id)
    {
        return syMajorMapper.deleteSyMajorById(id);
    }
}
