package com.corewing.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.common.Result;
import com.corewing.app.dto.qc.ValidateWirelessBoardRequest;
import com.corewing.app.entity.BizDevice;
import com.corewing.app.mapper.BizDeviceMapper;
import com.corewing.app.service.BizDeviceService;
import org.springframework.stereotype.Service;

@Service
public class BizDeviceServiceImpl extends ServiceImpl<BizDeviceMapper, BizDevice> implements BizDeviceService {
    @Override
    public Result<Boolean> validateWirelessBoard(ValidateWirelessBoardRequest validateWirelessBoardRequest) {

        LambdaQueryWrapper<BizDevice> bizDeviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
        bizDeviceLambdaQueryWrapper.eq(BizDevice::getDeviceMac, validateWirelessBoardRequest.getMac());
        long deviceCount = count(bizDeviceLambdaQueryWrapper);
        if (deviceCount > 0) {
            return Result.success(true);
        }

        return Result.error("设备不存在或未激活");
    }
}
