package com.meas.system.service.impl;

import com.meas.common.utils.DateUtils;
import com.meas.system.domain.MeasEnvData;
import com.meas.system.mapper.MeasEnvDataMapper;
import com.meas.system.service.IMeasEnvDataService;
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 MeasEnvDataServiceImpl implements IMeasEnvDataService {
    @Autowired
    private MeasEnvDataMapper measEnvDataMapper;

    /**
     * 查询测量环境数据
     *
     * @param id 测量环境数据主键
     * @return 测量环境数据
     */
    @Override
    public MeasEnvData selectMeasEnvDataById(Long id) {
        return measEnvDataMapper.selectMeasEnvDataById(id);
    }

    /**
     * 查询测量环境数据列表
     *
     * @param measEnvData 测量环境数据
     * @return 测量环境数据
     */
    @Override
    public List<MeasEnvData> selectMeasEnvDataList(MeasEnvData measEnvData) {
        return measEnvDataMapper.selectMeasEnvDataList(measEnvData);
    }

    /**
     * 新增测量环境数据
     *
     * @param measEnvData 测量环境数据
     * @return 结果
     */
    @Override
    public MeasEnvData insertMeasEnvData(MeasEnvData measEnvData) {
        measEnvData.setCreateTime(DateUtils.getNowDate());
        int i = measEnvDataMapper.insertMeasEnvData(measEnvData);
        if (i > 0) {
            return measEnvData;
        } else {
            return null;
        }
    }

    /**
     * 修改测量环境数据
     *
     * @param measEnvData 测量环境数据
     * @return 结果
     */
    @Override
    public int updateMeasEnvData(MeasEnvData measEnvData) {
        measEnvData.setUpdateTime(DateUtils.getNowDate());
        return measEnvDataMapper.updateMeasEnvData(measEnvData);
    }

    /**
     * 批量删除测量环境数据
     *
     * @param ids 需要删除的测量环境数据主键
     * @return 结果
     */
    @Override
    public int deleteMeasEnvDataByIds(Long[] ids) {
        return measEnvDataMapper.deleteMeasEnvDataByIds(ids);
    }

    /**
     * 删除测量环境数据信息
     *
     * @param id 测量环境数据主键
     * @return 结果
     */
    @Override
    public int deleteMeasEnvDataById(Long id) {
        return measEnvDataMapper.deleteMeasEnvDataById(id);
    }
}
