package com.ruoyi.sim.service.impl;

import java.util.List;

import com.ruoyi.sim.domain.Major;
import com.ruoyi.sim.mapper.MajorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sim.mapper.AddOnDeptMapper;
import com.ruoyi.sim.domain.AddOnDept;

/**
 * 部门附加Service业务层处理
 *
 * @author tom
 * @date 2024-12-13
 */
@Service
public class AddOnDeptService  {
    @Autowired
    private AddOnDeptMapper addOnDeptMapper;

    /**
     * 查询部门附加
     *
     * @param deptId 部门附加主键
     * @return 部门附加
     */
    public AddOnDept selectAddOnDeptByDeptId(Long deptId) {
        return addOnDeptMapper.selectAddOnDeptByDeptId(deptId);
    }

    /**
     * 查询部门附加列表
     *
     * @param addOnDept 部门附加
     * @return 部门附加
     */
    public List<AddOnDept> selectAddOnDeptList(AddOnDept addOnDept) {
        return addOnDeptMapper.selectAddOnDeptList(addOnDept);
    }

    /**
     * 新增部门附加
     *
     * @param addOnDept 部门附加
     * @return 结果
     */
    public int insertAddOnDept(AddOnDept addOnDept) {
        return addOnDeptMapper.insertAddOnDept(addOnDept);
    }

    /**
     * 修改部门附加
     *
     * @param addOnDept 部门附加
     * @return 结果
     */
    public int updateAddOnDept(AddOnDept addOnDept) {
        return addOnDeptMapper.updateAddOnDept(addOnDept);
    }

    /**
     * 批量删除部门附加
     *
     * @param deptIds 需要删除的部门附加主键
     * @return 结果
     */
    public int deleteAddOnDeptByDeptIds(Long[] deptIds) {
        return addOnDeptMapper.deleteAddOnDeptByDeptIds(deptIds);
    }

    /**
     * 删除部门附加信息
     *
     * @param deptId 部门附加主键
     * @return 结果
     */
    public int deleteAddOnDeptByDeptId(Long deptId) {
        return addOnDeptMapper.deleteAddOnDeptByDeptId(deptId);
    }

    // -------------------------------- tom add  --------------------------------
    @Autowired
    private MajorMapper majorMapper;

    public Major selectMajorByDeptId(Long deptId) {
        AddOnDept aoD = addOnDeptMapper.selectAddOnDeptByDeptId(deptId);
        if (aoD == null) {
            return null;
        }
        return majorMapper.selectMajorByMajorId(aoD.getMajorId());
    }
}
