package com.bonus.material.scrap.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.scrap.mapper.ScrapApplyDetailsMapper;
import com.bonus.material.scrap.domain.ScrapApplyDetails;
import com.bonus.material.scrap.service.IScrapApplyDetailsService;

/**
 * 报废任务详细Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
    @Autowired
    private ScrapApplyDetailsMapper scrapApplyDetailsMapper;

    /**
     * 查询报废任务详细
     * 
     * @param id 报废任务详细主键
     * @return 报废任务详细
     */
    @Override
    public ScrapApplyDetails selectScrapApplyDetailsById(Long id) {
        return scrapApplyDetailsMapper.selectScrapApplyDetailsById(id);
    }

    /**
     * 查询报废任务详细列表
     * 
     * @param scrapApplyDetails 报废任务详细
     * @return 报废任务详细
     */
    @Override
    public List<ScrapApplyDetails> selectScrapApplyDetailsList(ScrapApplyDetails scrapApplyDetails) {
        return scrapApplyDetailsMapper.selectScrapApplyDetailsList(scrapApplyDetails);
    }

    /**
     * 新增报废任务详细
     * 
     * @param scrapApplyDetails 报废任务详细
     * @return 结果
     */
    @Override
    public int insertScrapApplyDetails(ScrapApplyDetails scrapApplyDetails) {
        scrapApplyDetails.setCreateTime(DateUtils.getNowDate());
        try {
            return scrapApplyDetailsMapper.insertScrapApplyDetails(scrapApplyDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改报废任务详细
     * 
     * @param scrapApplyDetails 报废任务详细
     * @return 结果
     */
    @Override
    public int updateScrapApplyDetails(ScrapApplyDetails scrapApplyDetails) {
        scrapApplyDetails.setUpdateTime(DateUtils.getNowDate());
        try {
            return scrapApplyDetailsMapper.updateScrapApplyDetails(scrapApplyDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除报废任务详细
     * 
     * @param ids 需要删除的报废任务详细主键
     * @return 结果
     */
    @Override
    public int deleteScrapApplyDetailsByIds(Long[] ids) {
        return scrapApplyDetailsMapper.deleteScrapApplyDetailsByIds(ids);
    }

    /**
     * 删除报废任务详细信息
     * 
     * @param id 报废任务详细主键
     * @return 结果
     */
    @Override
    public int deleteScrapApplyDetailsById(Long id) {
        return scrapApplyDetailsMapper.deleteScrapApplyDetailsById(id);
    }
}
