package com.meas.system.service.impl;

import com.meas.common.utils.DateUtils;
import com.meas.system.domain.MeasSpectralRadiation;
import com.meas.system.mapper.MeasSpectralRadiationMapper;
import com.meas.system.service.IMeasSpectralRadiationService;
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 MeasSpectralRadiationServiceImpl implements IMeasSpectralRadiationService {
    @Autowired
    private MeasSpectralRadiationMapper measSpectralRadiationMapper;

    /**
     * 查询光谱辐射
     *
     * @param id 光谱辐射主键
     * @return 光谱辐射
     */
    @Override
    public MeasSpectralRadiation selectMeasSpectralRadiationById(Long id) {
        return measSpectralRadiationMapper.selectMeasSpectralRadiationById(id);
    }

    /**
     * 查询光谱辐射列表
     *
     * @param measSpectralRadiation 光谱辐射
     * @return 光谱辐射
     */
    @Override
    public List<MeasSpectralRadiation> selectMeasSpectralRadiationList(MeasSpectralRadiation measSpectralRadiation) {
        return measSpectralRadiationMapper.selectMeasSpectralRadiationList(measSpectralRadiation);
    }

    /**
     * 新增光谱辐射
     *
     * @param measSpectralRadiation 光谱辐射
     * @return 结果
     */
    @Override
    public MeasSpectralRadiation insertMeasSpectralRadiation(MeasSpectralRadiation measSpectralRadiation) {
        measSpectralRadiation.setCreateTime(DateUtils.getNowDate());
        int i = measSpectralRadiationMapper.insertMeasSpectralRadiation(measSpectralRadiation);
        if (i > 0) {
            return measSpectralRadiation;
        } else {
            return null;
        }
    }

    /**
     * 修改光谱辐射
     *
     * @param measSpectralRadiation 光谱辐射
     * @return 结果
     */
    @Override
    public int updateMeasSpectralRadiation(MeasSpectralRadiation measSpectralRadiation) {
        measSpectralRadiation.setUpdateTime(DateUtils.getNowDate());
        return measSpectralRadiationMapper.updateMeasSpectralRadiation(measSpectralRadiation);
    }

    /**
     * 批量删除光谱辐射
     *
     * @param ids 需要删除的光谱辐射主键
     * @return 结果
     */
    @Override
    public int deleteMeasSpectralRadiationByIds(Long[] ids) {
        return measSpectralRadiationMapper.deleteMeasSpectralRadiationByIds(ids);
    }

    /**
     * 删除光谱辐射信息
     *
     * @param id 光谱辐射主键
     * @return 结果
     */
    @Override
    public int deleteMeasSpectralRadiationById(Long id) {
        return measSpectralRadiationMapper.deleteMeasSpectralRadiationById(id);
    }

    @Override
    public MeasSpectralRadiation selectResultsByEnvDataId(Long envDataId) {
        return measSpectralRadiationMapper.selectResultsByEnvDataId(envDataId);
    }
}
