package com.bonus.material.plan.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.plan.mapper.PlanBorrowInfoMapper;
import com.bonus.material.plan.domain.PlanBorrowInfo;
import com.bonus.material.plan.service.IPlanBorrowInfoService;

/**
 * 年度借调Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class PlanBorrowInfoServiceImpl implements IPlanBorrowInfoService {
    @Autowired
    private PlanBorrowInfoMapper planBorrowInfoMapper;

    /**
     * 查询年度借调
     * 
     * @param borrowId 年度借调主键
     * @return 年度借调
     */
    @Override
    public PlanBorrowInfo selectPlanBorrowInfoByBorrowId(Long borrowId) {
        return planBorrowInfoMapper.selectPlanBorrowInfoByBorrowId(borrowId);
    }

    /**
     * 查询年度借调列表
     * 
     * @param planBorrowInfo 年度借调
     * @return 年度借调
     */
    @Override
    public List<PlanBorrowInfo> selectPlanBorrowInfoList(PlanBorrowInfo planBorrowInfo) {
        return planBorrowInfoMapper.selectPlanBorrowInfoList(planBorrowInfo);
    }

    /**
     * 新增年度借调
     * 
     * @param planBorrowInfo 年度借调
     * @return 结果
     */
    @Override
    public int insertPlanBorrowInfo(PlanBorrowInfo planBorrowInfo) {
        planBorrowInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return planBorrowInfoMapper.insertPlanBorrowInfo(planBorrowInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改年度借调
     * 
     * @param planBorrowInfo 年度借调
     * @return 结果
     */
    @Override
    public int updatePlanBorrowInfo(PlanBorrowInfo planBorrowInfo) {
        planBorrowInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return planBorrowInfoMapper.updatePlanBorrowInfo(planBorrowInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除年度借调
     * 
     * @param borrowIds 需要删除的年度借调主键
     * @return 结果
     */
    @Override
    public int deletePlanBorrowInfoByBorrowIds(Long[] borrowIds) {
        return planBorrowInfoMapper.deletePlanBorrowInfoByBorrowIds(borrowIds);
    }

    /**
     * 删除年度借调信息
     * 
     * @param borrowId 年度借调主键
     * @return 结果
     */
    @Override
    public int deletePlanBorrowInfoByBorrowId(Long borrowId) {
        return planBorrowInfoMapper.deletePlanBorrowInfoByBorrowId(borrowId);
    }
}
