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.SetupTensionAllLine;
import com.fizz.business.mapper.SetupTensionAllLineMapper;
import com.fizz.business.service.ISetupTensionAllLineService;

/**
 * 全线张力Service业务层处理
 */
@Service
public class SetupTensionAllLineServiceImpl implements ISetupTensionAllLineService
{
    @Autowired
    private SetupTensionAllLineMapper mapper;

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

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

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

