package com.meas.system.service.impl;

import com.meas.common.utils.DateUtils;
import com.meas.system.domain.MeasTransmissionRate;
import com.meas.system.mapper.MeasTransmissionRateMapper;
import com.meas.system.service.IMeasTransmissionRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 透过率Service业务层处理
 *
 * @author wgk
 * @date 2024-06-13
 */
@Service
public class MeasTransmissionRateServiceImpl implements IMeasTransmissionRateService {
    @Autowired
    private MeasTransmissionRateMapper measTransmissionRateMapper;

    /**
     * 查询透过率
     *
     * @param id 透过率主键
     * @return 透过率
     */
    @Override
    public MeasTransmissionRate selectMeasTransmissionRateById(Long id) {
        return measTransmissionRateMapper.selectMeasTransmissionRateById(id);
    }

    /**
     * 查询透过率列表
     *
     * @param measTransmissionRate 透过率
     * @return 透过率
     */
    @Override
    public List<MeasTransmissionRate> selectMeasTransmissionRateList(MeasTransmissionRate measTransmissionRate) {
        return measTransmissionRateMapper.selectMeasTransmissionRateList(measTransmissionRate);
    }

    /**
     * 新增透过率
     *
     * @param measTransmissionRate 透过率
     * @return 结果
     */
    @Override
    public MeasTransmissionRate insertMeasTransmissionRate(MeasTransmissionRate measTransmissionRate) {
        measTransmissionRate.setCreateTime(DateUtils.getNowDate());
        int i = measTransmissionRateMapper.insertMeasTransmissionRate(measTransmissionRate);
        if (i > 0) {
            return measTransmissionRate;
        } else {
            return null;
        }
    }

    /**
     * 修改透过率
     *
     * @param measTransmissionRate 透过率
     * @return 结果
     */
    @Override
    public int updateMeasTransmissionRate(MeasTransmissionRate measTransmissionRate) {
        measTransmissionRate.setUpdateTime(DateUtils.getNowDate());
        return measTransmissionRateMapper.updateMeasTransmissionRate(measTransmissionRate);
    }

    /**
     * 批量删除透过率
     *
     * @param ids 需要删除的透过率主键
     * @return 结果
     */
    @Override
    public int deleteMeasTransmissionRateByIds(Long[] ids) {
        return measTransmissionRateMapper.deleteMeasTransmissionRateByIds(ids);
    }

    /**
     * 删除透过率信息
     *
     * @param id 透过率主键
     * @return 结果
     */
    @Override
    public int deleteMeasTransmissionRateById(Long id) {
        return measTransmissionRateMapper.deleteMeasTransmissionRateById(id);
    }

    @Override
    public MeasTransmissionRate selectResultsByEnvDataId(Long envDataId) {
        return measTransmissionRateMapper.selectResultsByEnvDataId(envDataId);
    }
}
