package com.zd.laboratory.service.impl;

import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.core.utils.SpringUtils;
import com.zd.common.security.service.TokenService;
import com.zd.laboratory.domain.LabApprovalDetail;
import com.zd.laboratory.mapper.LabApprovalDetailMapper;
import com.zd.laboratory.service.ILabApprovalDetailService;
import com.zd.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 安全准入审批记录提交资料Service业务层处理
 *
 * @author liubo
 * @date 2021-09-10
 */
@Service
public class LabApprovalDetailServiceImpl implements ILabApprovalDetailService {
    @Autowired
    private LabApprovalDetailMapper labApprovalDetailMapper;

    /**
     * 查询安全准入审批记录提交资料
     *
     * @param id 安全准入审批记录提交资料主键
     * @return 安全准入审批记录提交资料
     */
    @Override
    public LabApprovalDetail selectLabApprovalDetailById(Long id) {
        return labApprovalDetailMapper.selectLabApprovalDetailById(id);
    }

    /**
     * 查询安全准入审批记录提交资料列表
     *
     * @param labApprovalDetail 安全准入审批记录提交资料
     * @return 安全准入审批记录提交资料
     */
    @Override
    public List<LabApprovalDetail> selectLabApprovalDetailList(LabApprovalDetail labApprovalDetail) {
        return labApprovalDetailMapper.selectLabApprovalDetailList(labApprovalDetail);
    }

    /**
     * 新增安全准入审批记录提交资料
     *
     * @param labApprovalDetail 安全准入审批记录提交资料
     * @return 结果
     */
    @Override
    public int insertLabApprovalDetail(LabApprovalDetail labApprovalDetail) {
        labApprovalDetail.setCreateTime(DateUtils.getNowDate());
        labApprovalDetail.setCreateBy(SecurityUtils.getUsername());
        SysUser sysUser = SpringUtils.getBean(TokenService.class).getLoginUser().getSysUser();
        labApprovalDetail.setDeptId(sysUser.getDeptId());
        labApprovalDetail.setDeptName(sysUser.getDeptName());
        return labApprovalDetailMapper.insertLabApprovalDetail(labApprovalDetail);
    }

    /**
     * 修改安全准入审批记录提交资料
     *
     * @param labApprovalDetail 安全准入审批记录提交资料
     * @return 结果
     */
    @Override
    public int updateLabApprovalDetail(LabApprovalDetail labApprovalDetail) {
        return labApprovalDetailMapper.updateLabApprovalDetail(labApprovalDetail);
    }

    /**
     * 批量删除安全准入审批记录提交资料
     *
     * @param ids 需要删除的安全准入审批记录提交资料主键
     * @return 结果
     */
    @Override
    public int deleteLabApprovalDetailByIds(Long[] ids) {
        return labApprovalDetailMapper.deleteLabApprovalDetailByIds(ids);
    }

    /**
     * 删除安全准入审批记录提交资料信息
     *
     * @param id 安全准入审批记录提交资料主键
     * @return 结果
     */
    @Override
    public int deleteLabApprovalDetailById(Long id) {
        return labApprovalDetailMapper.deleteLabApprovalDetailById(id);
    }
}
