package com.dcs.hnyz.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import com.dcs.common.utils.DateUtils;
import com.dcs.hnyz.domain.EquipmentExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dcs.hnyz.mapper.ModelComponentMapper;
import com.dcs.hnyz.domain.ModelComponent;
import com.dcs.hnyz.service.IModelComponentService;

import javax.annotation.Resource;

/**
 * 模型组件管理Service业务层处理
 * 
 * @author hmy
 * @date 2025-07-04
 */
@Service
public class ModelComponentServiceImpl implements IModelComponentService 
{
    @Resource
    private ModelComponentMapper modelComponentMapper;

    /**
     * 查询模型组件管理
     * 
     * @param modelId 模型组件管理主键
     * @return 模型组件管理
     */
    @Override
    public ModelComponent selectModelComponentByModelId(Long modelId)
    {
        return modelComponentMapper.selectById(modelId);
    }

    /**
     * 查询模型组件管理列表
     * 
     * @param modelComponent 模型组件管理
     * @return 模型组件管理
     */
    @Override
    public List<ModelComponent> selectModelComponentList(ModelComponent modelComponent)
    {
        return modelComponentMapper.selectModelComponentList(modelComponent);
    }

    /**
     * 新增模型组件管理
     * 
     * @param modelComponent 模型组件管理
     * @return 结果
     */
    @Override
    public int insertModelComponent(ModelComponent modelComponent)
    {
//        modelComponent.setCreateTime(DateUtils.getNowDate());
        return modelComponentMapper.insert(modelComponent);
    }

    /**
     * 修改模型组件管理
     * 
     * @param modelComponent 模型组件管理
     * @return 结果
     */
    @Override
    public int updateModelComponent(ModelComponent modelComponent)
    {
//        modelComponent.setUpdateTime(DateUtils.getNowDate());
        return modelComponentMapper.updateById(modelComponent);
    }

    /**
     * 批量删除模型组件管理
     * 
     * @param modelIds 需要删除的模型组件管理主键
     * @return 结果
     */
    @Override
    public int deleteModelComponentByModelIds(Long[] modelIds)
    {
        return modelComponentMapper.deleteBatchIds(Arrays.asList(modelIds));
    }

    /**
     * 删除模型组件管理信息
     * 
     * @param modelId 模型组件管理主键
     * @return 结果
     */
    @Override
    public int deleteModelComponentByModelId(Long modelId)
    {
        return modelComponentMapper.deleteById(modelId);
    }


    @Override
    public Map<Long, ModelComponent> getModelMapByIds(Set<Long> modelIds) {
        if (modelIds == null || modelIds.isEmpty()) {
            return Collections.emptyMap();
        }
        return modelComponentMapper.selectBatchIds(modelIds).stream().collect(Collectors.toMap(ModelComponent::getModelId, modelComponent -> modelComponent));
    }

    @Override
    public List<ModelComponent> getModelComponentSelectList() {
        return modelComponentMapper.selectList(null);
    }
}
