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.PlanBorrowDetailsMapper;
import com.bonus.material.plan.domain.PlanBorrowDetails;
import com.bonus.material.plan.service.IPlanBorrowDetailsService;

/**
 * 年度借调计划详细Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class PlanBorrowDetailsServiceImpl implements IPlanBorrowDetailsService {
    @Autowired
    private PlanBorrowDetailsMapper planBorrowDetailsMapper;

    /**
     * 查询年度借调计划详细
     * 
     * @param planId 年度借调计划详细主键
     * @return 年度借调计划详细
     */
    @Override
    public PlanBorrowDetails selectPlanBorrowDetailsByPlanId(Long planId) {
        return planBorrowDetailsMapper.selectPlanBorrowDetailsByPlanId(planId);
    }

    /**
     * 查询年度借调计划详细列表
     * 
     * @param planBorrowDetails 年度借调计划详细
     * @return 年度借调计划详细
     */
    @Override
    public List<PlanBorrowDetails> selectPlanBorrowDetailsList(PlanBorrowDetails planBorrowDetails) {
        return planBorrowDetailsMapper.selectPlanBorrowDetailsList(planBorrowDetails);
    }

    /**
     * 新增年度借调计划详细
     * 
     * @param planBorrowDetails 年度借调计划详细
     * @return 结果
     */
    @Override
    public int insertPlanBorrowDetails(PlanBorrowDetails planBorrowDetails) {
        planBorrowDetails.setCreateTime(DateUtils.getNowDate());
        try {
            return planBorrowDetailsMapper.insertPlanBorrowDetails(planBorrowDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改年度借调计划详细
     * 
     * @param planBorrowDetails 年度借调计划详细
     * @return 结果
     */
    @Override
    public int updatePlanBorrowDetails(PlanBorrowDetails planBorrowDetails) {
        planBorrowDetails.setUpdateTime(DateUtils.getNowDate());
        try {
            return planBorrowDetailsMapper.updatePlanBorrowDetails(planBorrowDetails);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除年度借调计划详细
     * 
     * @param planIds 需要删除的年度借调计划详细主键
     * @return 结果
     */
    @Override
    public int deletePlanBorrowDetailsByPlanIds(Long[] planIds) {
        return planBorrowDetailsMapper.deletePlanBorrowDetailsByPlanIds(planIds);
    }

    /**
     * 删除年度借调计划详细信息
     * 
     * @param planId 年度借调计划详细主键
     * @return 结果
     */
    @Override
    public int deletePlanBorrowDetailsByPlanId(Long planId) {
        return planBorrowDetailsMapper.deletePlanBorrowDetailsByPlanId(planId);
    }
}
