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.PlanNeedDetailsMapper;
import com.bonus.material.plan.domain.PlanNeedDetails;
import com.bonus.material.plan.service.IPlanNeedDetailsService;

/**
 * 年度计划详细Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class PlanNeedDetailsServiceImpl implements IPlanNeedDetailsService {
    @Autowired
    private PlanNeedDetailsMapper planNeedDetailsMapper;

    /**
     * 查询年度计划详细
     * 
     * @param planId 年度计划详细主键
     * @return 年度计划详细
     */
    @Override
    public PlanNeedDetails selectPlanNeedDetailsByPlanId(Long planId) {
        return planNeedDetailsMapper.selectPlanNeedDetailsByPlanId(planId);
    }

    /**
     * 查询年度计划详细列表
     * 
     * @param planNeedDetails 年度计划详细
     * @return 年度计划详细
     */
    @Override
    public List<PlanNeedDetails> selectPlanNeedDetailsList(PlanNeedDetails planNeedDetails) {
        return planNeedDetailsMapper.selectPlanNeedDetailsList(planNeedDetails);
    }

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

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

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

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