package com.emoon.openplatform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.emoon.common.core.utils.StringUtils;
import com.emoon.openplatform.domain.ModelDo;
import com.emoon.openplatform.domain.bo.ModelBo;
import com.emoon.openplatform.mapper.ModelMapper;
import com.emoon.openplatform.service.IModelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author destiny
 * @description:
 * @date 2025/10/25 20:45
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class ModelServiceImpl implements IModelService {

    private final ModelMapper modelMapper;

    /**
     * @param bo
     * @return
     */
    @Override
    public List<ModelDo> search(ModelBo bo) {
        LambdaQueryWrapper<ModelDo> lqw = new LambdaQueryWrapper<ModelDo>()
            .eq(StringUtils.isNotBlank(bo.getModel()), ModelDo::getModel, bo.getModel())
            .eq(bo.getNetwork() != null, ModelDo::getNetwork, bo.getNetwork())
            .eq(StringUtils.isNotBlank(bo.getCompany()), ModelDo::getCompany, bo.getCompany())
            .eq(StringUtils.isNotBlank(bo.getIntroduce()), ModelDo::getIntroduce, bo.getIntroduce());
        return modelMapper.selectList(lqw);
    }

    @Override
    public List<ModelDo> queryByIds(List<String> modelIds) {
        return modelMapper.selectList(
            new LambdaQueryWrapper<ModelDo>()
                .in(ModelDo::getId, modelIds)
        );
    }
}
