package com.yuchen.saas.park.service.service.security.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.dto.security.SaasParkSurveillanceCameraQryDto;
import com.yuchen.saas.park.api.entity.security.SaasParkSurveillanceCamera;
import com.yuchen.saas.park.service.mapper.security.SaasParkSurveillanceCameraMapper;
import com.yuchen.saas.park.service.service.security.ISaasParkSurveillanceCameraService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 视频监控设备表 服务实现类
 * </p>
 *
 * @author 洪铭铭
 * @since 2024-09-12
 */
@Service
public class SaasParkSurveillanceCameraServiceImpl extends BaseServiceImpl<SaasParkSurveillanceCameraMapper, SaasParkSurveillanceCamera> implements ISaasParkSurveillanceCameraService {
    public List<SaasParkSurveillanceCamera> getAll() {

        LambdaQueryWrapper<SaasParkSurveillanceCamera> qw = new LambdaQueryWrapper<>();
        List<SaasParkSurveillanceCamera> saasParkSurveillanceCameraList = baseMapper.selectList(qw);

        return saasParkSurveillanceCameraList;
    }

    public IPage<SaasParkSurveillanceCamera> selectPage(SaasParkSurveillanceCameraQryDto qryDto) {
        Page<SaasParkSurveillanceCamera> page = new Page<>(qryDto.getCurrent(), qryDto.getSize());
        LambdaQueryWrapper<SaasParkSurveillanceCamera> qw = new LambdaQueryWrapper<>();
//        if (!AuthUtil.isAdministrator()) {
//            qw.eq(SaasParkSurveillanceCamera::getCustomerManageId, AuthUtil.getUser().getCustomerManageId());
//        } else {
//            // 超管
//            qw.eq(Func.isNotEmpty(qryDto.getCustomerManageId()), SaasParkSurveillanceCamera::getCustomerManageId, qryDto.getCustomerManageId());
//        }
        qw.eq(Func.isNotEmpty(qryDto.getParkId()), SaasParkSurveillanceCamera::getParkId, qryDto.getParkId());
        qw.eq(Func.isNotEmpty(qryDto.getDeviceName()), SaasParkSurveillanceCamera::getDeviceName, qryDto.getDeviceName());
        qw.eq(Func.isNotEmpty(qryDto.getProductKey()), SaasParkSurveillanceCamera::getProductKey, qryDto.getProductKey());
        //qw.eq(Func.isNotEmpty(qryDto.getDeviceDesc()), SaasParkSurveillanceCamera::getDeviceDesc, qryDto.getDeviceDesc());
        qw.eq(Func.isNotEmpty(qryDto.getCameraType()), SaasParkSurveillanceCamera::getCameraType, qryDto.getCameraType());
        qw.eq(Func.isNotEmpty(qryDto.getDeviceStatus()), SaasParkSurveillanceCamera::getDeviceStatus, qryDto.getDeviceStatus());
        qw.eq(Func.isNotEmpty(qryDto.getInstallLocation()), SaasParkSurveillanceCamera::getInstallLocation, qryDto.getInstallLocation());
        qw.eq(Func.isNotEmpty(qryDto.getLatitude()), SaasParkSurveillanceCamera::getLatitude, qryDto.getLatitude());
        qw.eq(Func.isNotEmpty(qryDto.getLongitude()), SaasParkSurveillanceCamera::getLongitude, qryDto.getLongitude());
        qw.eq(Func.isNotEmpty(qryDto.getLastConnectTime()), SaasParkSurveillanceCamera::getLastConnectTime, qryDto.getLastConnectTime());
        qw.eq(Func.isNotEmpty(qryDto.getLastDisconnectTime()), SaasParkSurveillanceCamera::getLastDisconnectTime, qryDto.getLastDisconnectTime());
        return this.page(page, qw);
    }

}
