package com.ruoyi.project.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.system.domain.ProductMaterial;
import com.ruoyi.project.system.mapper.ProductMaterialMapper;
import com.ruoyi.project.system.service.IProductMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 材质Service业务层处理
 * 
 * @author zhu
 * @date 2023-10-24
 */
@Service
public class ProductMaterialServiceImpl implements IProductMaterialService 
{
    @Autowired
    private ProductMaterialMapper productMaterialMapper;

    /**
     * 查询材质
     * 
     * @param id 材质主键
     * @return 材质
     */
    @Override
    public ProductMaterial selectProductMaterialById(Long id)
    {
        return productMaterialMapper.selectProductMaterialById(id);
    }

    /**
     * 查询材质列表
     * 
     * @param productMaterial 材质
     * @return 材质
     */
    @Override
    public List<ProductMaterial> selectProductMaterialList(ProductMaterial productMaterial)
    {
        return productMaterialMapper.selectProductMaterialList(productMaterial);
    }

    /**
     * 新增材质
     * 
     * @param productMaterial 材质
     * @return 结果
     */
    @Override
    public int insertProductMaterial(ProductMaterial productMaterial)
    {
        productMaterial.setCreateTime(DateUtils.getNowDate());
        return productMaterialMapper.insertProductMaterial(productMaterial);
    }

    /**
     * 修改材质
     * 
     * @param productMaterial 材质
     * @return 结果
     */
    @Override
    public int updateProductMaterial(ProductMaterial productMaterial)
    {
        productMaterial.setUpdateTime(DateUtils.getNowDate());
        return productMaterialMapper.updateProductMaterial(productMaterial);
    }

    /**
     * 批量删除材质
     * 
     * @param ids 需要删除的材质主键
     * @return 结果
     */
    @Override
    public int deleteProductMaterialByIds(Long[] ids)
    {
        return productMaterialMapper.deleteProductMaterialByIds(ids);
    }

    /**
     * 删除材质信息
     * 
     * @param id 材质主键
     * @return 结果
     */
    @Override
    public int deleteProductMaterialById(Long id)
    {
        return productMaterialMapper.deleteProductMaterialById(id);
    }
}
