package com.fizz.business.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fizz.business.domain.SetupTensionLeveler;
import com.fizz.business.mapper.SetupTensionLevelerMapper;
import com.fizz.business.service.ISetupTensionLevelerService;

/**
 * 平整机张力Service业务层处理
 */
@Service
public class SetupTensionLevelerServiceImpl implements ISetupTensionLevelerService
{
    @Autowired
    private SetupTensionLevelerMapper mapper;

    @Override
    public SetupTensionLeveler selectByKey(String steelGrade, Float thick, Float yieldStren)
    {
        return mapper.selectByKey(steelGrade, thick, yieldStren);
    }

    @Override
    public List<SetupTensionLeveler> selectList(SetupTensionLeveler query)
    {
        return mapper.selectList(query);
    }

    @Override
    public int insert(SetupTensionLeveler entity)
    {
        if (mapper.selectByKey(entity.getSteelGrade(), entity.getThick(), entity.getYieldStren()) != null) {
            throw new RuntimeException("This parameter already exists");
        }
        entity.setCreateTime(DateUtils.getNowDate());
        entity.setUpdateTime(DateUtils.getNowDate());
        return mapper.insert(entity);
    }

    @Override
    public int updateByKey(SetupTensionLeveler entity)
    {
        entity.setUpdateTime(DateUtils.getNowDate());
        return mapper.updateByKey(entity);
    }

    @Override
    public int deleteByKey(String steelGrade, Float thick, Float yieldStren)
    {
        return mapper.deleteByKey(steelGrade, thick, yieldStren);
    }
}

