package com.bonus.material.repair.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.repair.mapper.RepairPartDetailsMapper;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.bonus.material.repair.service.IRepairPartDetailsService;

/**
 * 维修配件详细Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class RepairPartDetailsServiceImpl implements IRepairPartDetailsService {
    @Autowired
    private RepairPartDetailsMapper repairPartDetailsMapper;

    /**
     * 查询维修配件详细
     * 
     * @param id 维修配件详细主键
     * @return 维修配件详细
     */
    @Override
    public RepairPartDetails selectRepairPartDetailsById(Long id) {
        return repairPartDetailsMapper.selectRepairPartDetailsById(id);
    }

    /**
     * 查询维修配件详细列表
     * 
     * @param repairPartDetails 维修配件详细
     * @return 维修配件详细
     */
    @Override
    public List<RepairPartDetails> selectRepairPartDetailsList(RepairPartDetails repairPartDetails) {
        return repairPartDetailsMapper.selectRepairPartDetailsList(repairPartDetails);
    }

    /**
     * 新增维修配件详细
     * 
     * @param repairPartDetails 维修配件详细
     * @return 结果
     */
    @Override
    public int insertRepairPartDetails(RepairPartDetails repairPartDetails) {
        repairPartDetails.setCreateTime(DateUtils.getNowDate());
        try {
            return repairPartDetailsMapper.insertRepairPartDetails(repairPartDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改维修配件详细
     * 
     * @param repairPartDetails 维修配件详细
     * @return 结果
     */
    @Override
    public int updateRepairPartDetails(RepairPartDetails repairPartDetails) {
        repairPartDetails.setUpdateTime(DateUtils.getNowDate());
        try {
            return repairPartDetailsMapper.updateRepairPartDetails(repairPartDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除维修配件详细
     * 
     * @param ids 需要删除的维修配件详细主键
     * @return 结果
     */
    @Override
    public int deleteRepairPartDetailsByIds(Long[] ids) {
        return repairPartDetailsMapper.deleteRepairPartDetailsByIds(ids);
    }

    /**
     * 删除维修配件详细信息
     * 
     * @param id 维修配件详细主键
     * @return 结果
     */
    @Override
    public int deleteRepairPartDetailsById(Long id) {
        return repairPartDetailsMapper.deleteRepairPartDetailsById(id);
    }
}
