package com.cmvr.ti.service.impl;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cmvr.ti.mapper.TiVehicleFunctionMapper;
import com.cmvr.ti.model.domain.TiVehicleFunction;
import com.cmvr.ti.service.ITiVehicleFunctionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 车机功能Service业务层处理
 */
@Service
@RequiredArgsConstructor
public class TiVehicleFunctionServiceImpl extends ServiceImpl<TiVehicleFunctionMapper, TiVehicleFunction> implements ITiVehicleFunctionService {

    @Override
    public TiVehicleFunction selectTiVehicleFunctionById(Long id) {
        return this.getById(id);
    }

    @Override
    public List<TiVehicleFunction> selectTiVehicleFunctionList(TiVehicleFunction tiVehicleFunction) {
        LambdaQueryWrapper<TiVehicleFunction> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotEmpty(tiVehicleFunction.getFuncKey()), TiVehicleFunction::getFuncKey, tiVehicleFunction.getFuncKey())
                .like(StrUtil.isNotEmpty(tiVehicleFunction.getRemark()), TiVehicleFunction::getRemark, tiVehicleFunction.getRemark());
        return this.list(wrapper);
    }

    @Override
    public int insertTiVehicleFunction(TiVehicleFunction TiVehicleFunction) {
        return this.baseMapper.insert(TiVehicleFunction);
    }

    @Override
    public int updateTiVehicleFunction(TiVehicleFunction TiVehicleFunction) {
        return this.baseMapper.updateById(TiVehicleFunction);
    }

    @Override
    public int deleteTiVehicleFunctionByIds(Long[] ids) {
        return this.baseMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
