package com.zd.system.service.impl;

import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.datascope.annotation.DataScope;
import com.zd.common.security.utils.SaveUtil;
import com.zd.system.domain.SysMajor;
import com.zd.system.mapper.SysMajorMapper;
import com.zd.system.service.ISysMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * majorService业务层处理
 *
 * @author zd
 * @date 2021-12-10
 */
@Service
public class SysMajorServiceImpl implements ISysMajorService {
    @Autowired
    private SysMajorMapper sysMajorMapper;

    /**
     * 查询major
     *
     * @param id major主键
     * @return major
     */
    @Override
    public SysMajor selectSysMajorById(Long id) {
        return sysMajorMapper.selectSysMajorById(id);
    }

    /**
     * 查询major列表
     *
     * @param sysMajor major
     * @return major
     */
    @Override
    @DataScope(deptAlias = "t", permi = PerPrefix.SYSTEM_MAJOR)
    public List<SysMajor> selectSysMajorList(SysMajor sysMajor) {
        return sysMajorMapper.selectSysMajorList(sysMajor);
    }

    /**
     * 新增major
     *
     * @param sysMajor major
     * @return 结果
     */
    @Override
    public int insertSysMajor(SysMajor sysMajor) {
        //设置其他公共字段
        SaveUtil.setCommonAttr(sysMajor);
        return sysMajorMapper.insertSysMajor(sysMajor);
    }

    /**
     * 修改major
     *
     * @param sysMajor major
     * @return 结果
     */
    @Override
    public int updateSysMajor(SysMajor sysMajor) {
        return sysMajorMapper.updateSysMajor(sysMajor);
    }

    /**
     * 批量删除major
     *
     * @param ids 需要删除的major主键
     * @return 结果
     */
    @Override
    public int deleteSysMajorByIds(Long[] ids) {
        return sysMajorMapper.deleteSysMajorByIds(ids);
    }

    /**
     * 删除major信息
     *
     * @param id major主键
     * @return 结果
     */
    @Override
    public int deleteSysMajorById(Long id) {
        return sysMajorMapper.deleteSysMajorById(id);
    }

    /**
     * 根据权限查询
     *
     * @param sysMajor
     * @return
     */
    @Override
    @DataScope(deptAlias = "t", permi = PerPrefix.SYSTEM_MAJOR)
    public List<SysMajor> selectSysMajorListPower(SysMajor sysMajor) {
        return sysMajorMapper.selectSysMajorListPower(sysMajor);
    }
}
