package com.zd.laboratory.service.impl;

import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.datascope.annotation.DataScope;
import com.zd.common.security.utils.SaveUtil;
import com.zd.laboratory.domain.LabSafeClassified;
import com.zd.laboratory.mapper.LabSafeClassifiedMapper;
import com.zd.laboratory.service.ILabSafeClassifiedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 安全分级Service业务层处理
 *
 * @author zd
 * @date 2021-12-18
 */
@Service
public class LabSafeClassifiedServiceImpl implements ILabSafeClassifiedService
{
    @Autowired
    private LabSafeClassifiedMapper labSafeClassifiedMapper;

    /**
     * 查询安全分级
     *
     * @param id 安全分级主键
     * @return 安全分级
     */
    @Override
    public LabSafeClassified selectLabSafeClassifiedById(Long id)
    {
        return labSafeClassifiedMapper.selectLabSafeClassifiedById(id);
    }

    /**
     * 查询安全分级列表
     *
     * @param labSafeClassified 安全分级
     * @return 安全分级
     */
    @Override
    @DataScope(deptAlias = "t" , permi = PerPrefix.LABORATORY_CLASSTYPE)
    public List<LabSafeClassified> selectLabSafeClassifiedList(LabSafeClassified labSafeClassified)
    {
        return labSafeClassifiedMapper.selectLabSafeClassifiedList(labSafeClassified);
    }

    /**
     * 新增安全分级
     *
     * @param labSafeClassified 安全分级
     * @return 结果
     */
    @Override
    public int insertLabSafeClassified(LabSafeClassified labSafeClassified)
    {
        //设置其他公共字段
        SaveUtil.setCommonAttr(labSafeClassified);
        return labSafeClassifiedMapper.insertLabSafeClassified(labSafeClassified);
    }

    /**
     * 修改安全分级
     *
     * @param labSafeClassified 安全分级
     * @return 结果
     */
    @Override
    public int updateLabSafeClassified(LabSafeClassified labSafeClassified)
    {
        labSafeClassified.setUpdateTime(DateUtils.getNowDate());
        labSafeClassified.setUpdateBy(SecurityUtils.getUsername());
        return labSafeClassifiedMapper.updateLabSafeClassified(labSafeClassified);
    }

    /**
     * 批量删除安全分级
     *
     * @param ids 需要删除的安全分级主键
     * @return 结果
     */
    @Override
    public int deleteLabSafeClassifiedByIds(Long[] ids)
    {
        return labSafeClassifiedMapper.deleteLabSafeClassifiedByIds(ids);
    }

    /**
     * 删除安全分级信息
     *
     * @param id 安全分级主键
     * @return 结果
     */
    @Override
    public int deleteLabSafeClassifiedById(Long id)
    {
        return labSafeClassifiedMapper.deleteLabSafeClassifiedById(id);
    }
}
