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.SetupTensionStraightener;
import com.fizz.business.mapper.SetupTensionStraightenerMapper;
import com.fizz.business.service.ISetupTensionStraightenerService;

/**
 * 矫直机张力Service业务层处理
 */
@Service
public class SetupTensionStraightenerServiceImpl implements ISetupTensionStraightenerService
{
    @Autowired
    private SetupTensionStraightenerMapper mapper;

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

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

    @Override
    public int insert(SetupTensionStraightener entity)
    {
        if (mapper.selectByKey(entity.getSteelGrade(), entity.getThick(), entity.getYieldStren()) != null) {
            throw new RuntimeException("该参数已存在");
        }
        entity.setCreateTime(DateUtils.getNowDate());
        entity.setUpdateTime(DateUtils.getNowDate());
        return mapper.insert(entity);
    }

    @Override
    public int updateByKey(SetupTensionStraightener 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);
    }
}

