package com.zksy.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.base.domain.StationVideoDevice;
import com.zksy.base.mapper.StationVideoDeviceMapper;
import com.zksy.base.service.StationVideoDeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class StationVideoDeviceServiceImpl extends ServiceImpl<StationVideoDeviceMapper, StationVideoDevice>
        implements StationVideoDeviceService {

    @Override
    public Page<StationVideoDevice> findByPage(long pageNum, long pageSize,
                                               String deviceName, String stationId, String status) {
        Page<StationVideoDevice> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<StationVideoDevice> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(deviceName != null && !deviceName.isEmpty(), StationVideoDevice::getDeviceName, deviceName);
        wrapper.eq(stationId != null && !stationId.isEmpty(), StationVideoDevice::getStationId, stationId);
        wrapper.eq(status != null && !status.isEmpty(), StationVideoDevice::getStatus, status);
        wrapper.orderByDesc(StationVideoDevice::getCreateTime);
        return this.page(page, wrapper);
    }
}
