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.datascope.annotation.DataScope;
import com.zd.common.security.utils.SaveUtil;
import com.zd.common.core.utils.SecurityUtils;

import com.zd.laboratory.domain.vo.LabSecurityMaterialDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.laboratory.mapper.LabSecurityMaterialDataMapper;
import com.zd.laboratory.domain.LabSecurityMaterialData;
import com.zd.laboratory.service.ILabSecurityMaterialDataService;

/**
 * 安全准入申请材料配置Service业务层处理
 *
 * @author zd
 * @date 2022-01-24
 */
@Service
public class LabSecurityMaterialDataServiceImpl implements ILabSecurityMaterialDataService
{
    @Autowired
    private LabSecurityMaterialDataMapper labSecurityMaterialDataMapper;

    /**
     * 查询安全准入申请材料配置
     *
     * @param id 安全准入申请材料配置主键
     * @return 安全准入申请材料配置
     */
    @Override
    public LabSecurityMaterialData selectLabSecurityMaterialDataById(Long id)
    {
        return labSecurityMaterialDataMapper.selectLabSecurityMaterialDataById(id);
    }

    /**
     * 查询安全准入申请材料配置列表
     *
     * @param labSecurityMaterialData 安全准入申请材料配置
     * @return 安全准入申请材料配置
     */
    @Override
    @DataScope(deptAlias = "d" , userAlias = "u" , permi = PerPrefix.LABORATORY_MATERIALDATA)
    public List<LabSecurityMaterialData> selectLabSecurityMaterialDataList(LabSecurityMaterialData labSecurityMaterialData)
    {
        return labSecurityMaterialDataMapper.selectLabSecurityMaterialDataList(labSecurityMaterialData);
    }

    /**
     * 新增安全准入申请材料配置
     *
     * @param labSecurityMaterialData 安全准入申请材料配置
     * @return 结果
     */
    @Override
    public int insertLabSecurityMaterialData(LabSecurityMaterialData labSecurityMaterialData)
    {
        //设置其他公共字段
        SaveUtil.setCommonAttr(labSecurityMaterialData);
        return labSecurityMaterialDataMapper.insertLabSecurityMaterialData(labSecurityMaterialData);
    }

    /**
     * 修改安全准入申请材料配置
     *
     * @param labSecurityMaterialData 安全准入申请材料配置
     * @return 结果
     */
    @Override
    public int updateLabSecurityMaterialData(LabSecurityMaterialData labSecurityMaterialData)
    {
        labSecurityMaterialData.setUpdateTime(DateUtils.getNowDate());
        labSecurityMaterialData.setUpdateUsername(SecurityUtils.getUsername());
        labSecurityMaterialData.setUpdateUserid(SecurityUtils.getUserId());
        return labSecurityMaterialDataMapper.updateLabSecurityMaterialData(labSecurityMaterialData);
    }

    /**
     * 批量删除安全准入申请材料配置
     *
     * @param ids 需要删除的安全准入申请材料配置主键
     * @return 结果
     */
    @Override
    public int deleteLabSecurityMaterialDataByIds(Long[] ids)
    {
        return labSecurityMaterialDataMapper.deleteLabSecurityMaterialDataByIds(ids);
    }

    /**
     * 删除安全准入申请材料配置信息
     *
     * @param id 安全准入申请材料配置主键
     * @return 结果
     */
    @Override
    public int deleteLabSecurityMaterialDataById(Long id)
    {
        return labSecurityMaterialDataMapper.deleteLabSecurityMaterialDataById(id);
    }

    /**
     * 根据登录用户身份查询模板
     *
     * @param materialSuit
     * @return
     */
    @Override
    public List<LabSecurityMaterialData> selectLabSecurityMaterialDataByIdentity(Long[] materialSuit) {
        return labSecurityMaterialDataMapper.selectLabSecurityMaterialDataByIdentity(materialSuit);
    }

    /**
     * 老师模板
     *
     * @param subjectId
     * @return
     */
    @Override
    public List<LabSecurityMaterialDataVO> selectLabSecurityMaterialDataTeacher(Long subjectId) {
        return labSecurityMaterialDataMapper.selectLabSecurityMaterialDataTeacher(subjectId);
    }

    /***
     * 学生模板
     * @param subjectId
     * @return
     */
    @Override
    public List<LabSecurityMaterialDataVO> selectLabSecurityMaterialDataStudent(Long subjectId) {
        return labSecurityMaterialDataMapper.selectLabSecurityMaterialDataStudent(subjectId);
    }

    /**
     * 教职工模板
     *
     * @return
     */
    @Override
    public List<LabSecurityMaterialDataVO> selectTemplateTeacherList() {
        return labSecurityMaterialDataMapper.selectTemplateTeacherList();
    }

    /**
     * 学生模板
     *
     * @return
     */
    @Override
    public List<LabSecurityMaterialDataVO> selectTemplateStudentList() {
        return labSecurityMaterialDataMapper.selectTemplateStudentList();
    }
}
