package com.leromro.core.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leromro.common.core.domain.R;
import com.leromro.core.domain.vo.BusinessManagementVO;
import com.leromro.core.mapper.BusinessManagementMapper;
import com.leromro.common.utils.DateUtils;
import com.leromro.core.utils.ForestNodeManager;
import com.leromro.core.utils.ForestNodeMerger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.leromro.core.mapper.BusinessManagementMapper;
import com.leromro.core.domain.BusinessManagement;
import com.leromro.core.service.IBusinessManagementService;

/**
 * 业务管理(树形结构包含所有服务)Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-17
 */
@Service
public class BusinessManagementServiceImpl extends ServiceImpl<BusinessManagementMapper, BusinessManagement> implements IBusinessManagementService
{
    @Autowired
    private BusinessManagementMapper businessManagementMapper;

    /**
     * 查询业务管理(树形结构包含所有服务)
     * 
     * @param businessManagementId 业务管理(树形结构包含所有服务)主键
     * @return 业务管理(树形结构包含所有服务)
     */
    @Override
    public BusinessManagement selectBusinessManagementByBusinessManagementId(Long businessManagementId)
    {
        return businessManagementMapper.selectBusinessManagementByBusinessManagementId(businessManagementId);
    }

    /**
     * 查询业务管理(树形结构包含所有服务)列表
     * 
     * @param businessManagement 业务管理(树形结构包含所有服务)
     * @return 业务管理(树形结构包含所有服务)
     */
    @Override
    public List<BusinessManagement> selectBusinessManagementList(BusinessManagement businessManagement)
    {
        return businessManagementMapper.selectBusinessManagementList(businessManagement);
    }

    /**
     * 新增业务管理(树形结构包含所有服务)
     * 
     * @param businessManagement 业务管理(树形结构包含所有服务)
     * @return 结果
     */
    @Override
    public Boolean insertBusinessManagement(BusinessManagement businessManagement)
    {
        return this.save(businessManagement);
    }

    /**
     * 修改业务管理(树形结构包含所有服务)
     * 
     * @param businessManagement 业务管理(树形结构包含所有服务)
     * @return 结果
     */
    @Override
    public Boolean updateBusinessManagement(BusinessManagement businessManagement)
    {
        return this.updateById(businessManagement);
    }

    /**
     * 批量删除业务管理(树形结构包含所有服务)
     * 
     * @param businessManagementIds 需要删除的业务管理(树形结构包含所有服务)主键
     * @return 结果
     */
    @Override
    public int deleteBusinessManagementByBusinessManagementIds(Long[] businessManagementIds)
    {
        return businessManagementMapper.deleteBusinessManagementByBusinessManagementIds(businessManagementIds);
    }

    /**
     * 删除业务管理(树形结构包含所有服务)信息
     * 
     * @param businessManagementId 业务管理(树形结构包含所有服务)主键
     * @return 结果
     */
    @Override
    public int deleteBusinessManagementByBusinessManagementId(Long businessManagementId)
    {
        return businessManagementMapper.deleteBusinessManagementByBusinessManagementId(businessManagementId);
    }

    /**
     * 查询业务管理(树形结构)列表
     */
    @Override
    public R<List<BusinessManagementVO>> getTreeList(Long parentId) {
        List<BusinessManagementVO> list = baseMapper.getTreeList(parentId);
        list = ForestNodeMerger.merge(list);
        return R.ok(list);
    }
}
