package com.zd.laboratory.service.impl;

import java.util.List;

import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.datascope.annotation.DataScope;
import com.zd.system.api.domain.SysUser;
import com.zd.common.core.utils.SpringUtils;
import com.zd.common.security.service.TokenService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.laboratory.mapper.LabSubjectHardwarePositionMapper;
import com.zd.laboratory.domain.LabSubjectHardwarePosition;
import com.zd.laboratory.service.ILabSubjectHardwarePositionService;

/**
 * 实验室硬件位置Service业务层处理
 *
 * @author zd
 * @date 2021-09-16
 */
@Service
public class LabSubjectHardwarePositionServiceImpl implements ILabSubjectHardwarePositionService {
    @Autowired
    private LabSubjectHardwarePositionMapper labSubjectHardwarePositionMapper;

    /**
     * 查询实验室硬件位置
     *
     * @param id 实验室硬件位置主键
     * @return 实验室硬件位置
     */
    @Override
    public LabSubjectHardwarePosition selectLabSubjectHardwarePositionById(Long id) {
        return labSubjectHardwarePositionMapper.selectLabSubjectHardwarePositionById(id);
    }

    /**
     * 查询实验室硬件位置列表
     *
     * @param labSubjectHardwarePosition 实验室硬件位置
     * @return 实验室硬件位置
     */
    @Override
    @DataScope(deptAlias = "shp")
    public List<LabSubjectHardwarePosition> selectLabSubjectHardwarePositionList(LabSubjectHardwarePosition labSubjectHardwarePosition) {
        return labSubjectHardwarePositionMapper.selectLabSubjectHardwarePositionList(labSubjectHardwarePosition);
    }

    /**
     * 新增实验室硬件位置
     *
     * @param labSubjectHardwarePosition 实验室硬件位置
     * @return 结果
     */
    @Override
    public int insertLabSubjectHardwarePosition(LabSubjectHardwarePosition labSubjectHardwarePosition) {
        labSubjectHardwarePosition.setCreateTime(DateUtils.getNowDate());
        labSubjectHardwarePosition.setCreateBy(SecurityUtils.getUsername());
        //labSubjectHardwarePosition.setUserId(SecurityUtils.getUserId());
        SysUser sysUser = SpringUtils.getBean(TokenService.class).getLoginUser().getSysUser();
        labSubjectHardwarePosition.setDeptId(sysUser.getDeptId());
        labSubjectHardwarePosition.setDeptName(sysUser.getDeptName());
        return labSubjectHardwarePositionMapper.insertLabSubjectHardwarePosition(labSubjectHardwarePosition);
    }

    /**
     * 修改实验室硬件位置
     *
     * @param labSubjectHardwarePosition 实验室硬件位置
     * @return 结果
     */
    @Override
    public int updateLabSubjectHardwarePosition(LabSubjectHardwarePosition labSubjectHardwarePosition) {
        return labSubjectHardwarePositionMapper.updateLabSubjectHardwarePosition(labSubjectHardwarePosition);
    }

    /**
     * 批量删除实验室硬件位置
     *
     * @param ids 需要删除的实验室硬件位置主键
     * @return 结果
     */
    @Override
    public int deleteLabSubjectHardwarePositionByIds(Long[] ids) {
        return labSubjectHardwarePositionMapper.deleteLabSubjectHardwarePositionByIds(ids);
    }

    /**
     * 删除实验室硬件位置信息
     *
     * @param id 实验室硬件位置主键
     * @return 结果
     */
    @Override
    public int deleteLabSubjectHardwarePositionById(Long id) {
        return labSubjectHardwarePositionMapper.deleteLabSubjectHardwarePositionById(id);
    }
}
