package com.bonus.material.purchase.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.purchase.mapper.PurchasePartInfoMapper;
import com.bonus.material.purchase.domain.PurchasePartInfo;
import com.bonus.material.purchase.service.IPurchasePartInfoService;

/**
 * 新购配件验收任务Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class PurchasePartInfoServiceImpl implements IPurchasePartInfoService {
    @Autowired
    private PurchasePartInfoMapper purchasePartInfoMapper;

    /**
     * 查询新购配件验收任务
     * 
     * @param ID 新购配件验收任务主键
     * @return 新购配件验收任务
     */
    @Override
    public PurchasePartInfo selectPurchasePartInfoByID(Long ID) {
        return purchasePartInfoMapper.selectPurchasePartInfoByID(ID);
    }

    /**
     * 查询新购配件验收任务列表
     * 
     * @param purchasePartInfo 新购配件验收任务
     * @return 新购配件验收任务
     */
    @Override
    public List<PurchasePartInfo> selectPurchasePartInfoList(PurchasePartInfo purchasePartInfo) {
        return purchasePartInfoMapper.selectPurchasePartInfoList(purchasePartInfo);
    }

    /**
     * 新增新购配件验收任务
     * 
     * @param purchasePartInfo 新购配件验收任务
     * @return 结果
     */
    @Override
    public int insertPurchasePartInfo(PurchasePartInfo purchasePartInfo) {
        purchasePartInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return purchasePartInfoMapper.insertPurchasePartInfo(purchasePartInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改新购配件验收任务
     * 
     * @param purchasePartInfo 新购配件验收任务
     * @return 结果
     */
    @Override
    public int updatePurchasePartInfo(PurchasePartInfo purchasePartInfo) {
        purchasePartInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return purchasePartInfoMapper.updatePurchasePartInfo(purchasePartInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除新购配件验收任务
     * 
     * @param IDs 需要删除的新购配件验收任务主键
     * @return 结果
     */
    @Override
    public int deletePurchasePartInfoByIDs(Long[] IDs) {
        return purchasePartInfoMapper.deletePurchasePartInfoByIDs(IDs);
    }

    /**
     * 删除新购配件验收任务信息
     * 
     * @param ID 新购配件验收任务主键
     * @return 结果
     */
    @Override
    public int deletePurchasePartInfoByID(Long ID) {
        return purchasePartInfoMapper.deletePurchasePartInfoByID(ID);
    }
}
