package com.zd.laboratory.service.impl;

import java.util.List;

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.vo.LabExitLightVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.laboratory.mapper.LabExitLightMapper;
import com.zd.laboratory.domain.LabExitLight;
import com.zd.laboratory.service.ILabExitLightService;

/**
 * 逃生指引灯Service业务层处理
 *
 * @author zd
 * @date 2022-01-25
 */
@Service
public class LabExitLightServiceImpl implements ILabExitLightService
{
    @Autowired
    private LabExitLightMapper labExitLightMapper;

    /**
     * 查询逃生指引灯
     *
     * @param id 逃生指引灯主键
     * @return 逃生指引灯
     */
    @Override
    public LabExitLightVO selectLabExitLightById(Long id)
    {
        return labExitLightMapper.selectLabExitLightById(id);
    }

    /**
     * 查询逃生指引灯列表
     *
     * @param labExitLightVO 逃生指引灯
     * @return 逃生指引灯
     */
    @Override
    @DataScope(deptAlias = "b", userAlias = "el", permi = PerPrefix.LABORATORY_LIGHT)
    public List<LabExitLightVO> selectLabExitLightList(LabExitLightVO labExitLightVO)
    {
//        return labExitLightMapper.selectLabExitLightList(labExitLight);
        return labExitLightMapper.selectLabExitLightJoinList(labExitLightVO);
    }

    /**
     * 新增逃生指引灯
     *
     * @param labExitLight 逃生指引灯
     * @return 结果
     */
    @Override
    public int insertLabExitLight(LabExitLight labExitLight)
    {
        //设置其他公共字段
        SaveUtil.setCommonAttr(labExitLight);
        return labExitLightMapper.insertLabExitLight(labExitLight);
    }

    /**
     * 修改逃生指引灯
     *
     * @param labExitLight 逃生指引灯
     * @return 结果
     */
    @Override
    public int updateLabExitLight(LabExitLight labExitLight)
    {
        labExitLight.setUpdateTime(DateUtils.getNowDate());
        labExitLight.setUpdateBy(SecurityUtils.getUsername());
        return labExitLightMapper.updateLabExitLight(labExitLight);
    }

    /**
     * 批量删除逃生指引灯
     *
     * @param ids 需要删除的逃生指引灯主键
     * @return 结果
     */
    @Override
    public int deleteLabExitLightByIds(Long[] ids)
    {
        return labExitLightMapper.deleteLabExitLightByIds(ids);
    }

    /**
     * 删除逃生指引灯信息
     *
     * @param id 逃生指引灯主键
     * @return 结果
     */
    @Override
    public int deleteLabExitLightById(Long id)
    {
        return labExitLightMapper.deleteLabExitLightById(id);
    }
}
