package com.diagbot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.dto.QcTypePageDTO;
import com.diagbot.entity.QcType;
import com.diagbot.mapper.QcTypeMapper;
import com.diagbot.service.QcTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.vo.QcTypePageVO;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 质控类型标准 服务实现类
 * </p>
 *
 * @author gaodm
 * @time: 2024-04-13
 */
@Service
public class QcTypeServiceImpl extends ServiceImpl<QcTypeMapper, QcType> implements QcTypeService {
    @Override
    public IPage<QcTypePageDTO> getList(QcTypePageVO qcTypePageVO) {
        return baseMapper.getList(qcTypePageVO);
    }

    /**
     * 保存，并返回ID
     * @param qcType
     * @return
     */
    public Long saveT(QcType qcType){
        this.baseMapper.insert(qcType);
        QueryWrapper<QcType> qWrapper =new QueryWrapper<>();
        qWrapper.eq("name",qcType.getName());
        qWrapper.eq("hospital_id", qcType.getHospitalId());
        QcType entity=this.baseMapper.selectOne(qWrapper);
        return entity.getId();
    }
}
