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.RepairApplyRecordMapper;
import com.bonus.material.repair.domain.RepairApplyRecord;
import com.bonus.material.repair.service.IRepairApplyRecordService;

/**
 * 维修记录Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class RepairApplyRecordServiceImpl implements IRepairApplyRecordService {
    @Autowired
    private RepairApplyRecordMapper repairApplyRecordMapper;

    /**
     * 查询维修记录
     * 
     * @param id 维修记录主键
     * @return 维修记录
     */
    @Override
    public RepairApplyRecord selectRepairApplyRecordById(Long id) {
        return repairApplyRecordMapper.selectRepairApplyRecordById(id);
    }

    /**
     * 查询维修记录列表
     * 
     * @param repairApplyRecord 维修记录
     * @return 维修记录
     */
    @Override
    public List<RepairApplyRecord> selectRepairApplyRecordList(RepairApplyRecord repairApplyRecord) {
        return repairApplyRecordMapper.selectRepairApplyRecordList(repairApplyRecord);
    }

    /**
     * 新增维修记录
     * 
     * @param repairApplyRecord 维修记录
     * @return 结果
     */
    @Override
    public int insertRepairApplyRecord(RepairApplyRecord repairApplyRecord) {
        repairApplyRecord.setCreateTime(DateUtils.getNowDate());
        try {
            return repairApplyRecordMapper.insertRepairApplyRecord(repairApplyRecord);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改维修记录
     * 
     * @param repairApplyRecord 维修记录
     * @return 结果
     */
    @Override
    public int updateRepairApplyRecord(RepairApplyRecord repairApplyRecord) {
        repairApplyRecord.setUpdateTime(DateUtils.getNowDate());
        try {
            return repairApplyRecordMapper.updateRepairApplyRecord(repairApplyRecord);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除维修记录
     * 
     * @param ids 需要删除的维修记录主键
     * @return 结果
     */
    @Override
    public int deleteRepairApplyRecordByIds(Long[] ids) {
        return repairApplyRecordMapper.deleteRepairApplyRecordByIds(ids);
    }

    /**
     * 删除维修记录信息
     * 
     * @param id 维修记录主键
     * @return 结果
     */
    @Override
    public int deleteRepairApplyRecordById(Long id) {
        return repairApplyRecordMapper.deleteRepairApplyRecordById(id);
    }
}
