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.TiVehicleUiMapper;
import com.cmvr.ti.model.domain.TiVehicleUi;
import com.cmvr.ti.service.ITiVehicleUiService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * 车机界面Service业务层处理
 */
@Service
@RequiredArgsConstructor
public class TiVehicleUiServiceImpl extends ServiceImpl<TiVehicleUiMapper, TiVehicleUi> implements ITiVehicleUiService {

    @Override
    public TiVehicleUi selectTiVehicleUiById(Long id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public List<TiVehicleUi> selectTiVehicleUiList(TiVehicleUi tiVehicleUi) {
        LambdaQueryWrapper<TiVehicleUi> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TiVehicleUi::getVehicleConfigId, tiVehicleUi.getVehicleConfigId())
                .like(StrUtil.isNotEmpty(tiVehicleUi.getUiKey()), TiVehicleUi::getUiKey, tiVehicleUi.getUiKey())
                .like(StrUtil.isNotEmpty(tiVehicleUi.getRemark()), TiVehicleUi::getRemark, tiVehicleUi.getRemark());
        return this.list(wrapper);
    }

    @Override
    public int insertTiVehicleUi(TiVehicleUi tiVehicleUi) {
        return this.baseMapper.insert(tiVehicleUi);
    }

    @Override
    public int updateTiVehicleUi(TiVehicleUi tiVehicleUi) {
        return this.baseMapper.updateById(tiVehicleUi);
    }

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