package com.persagy.adm.server.custom.service.impl.check_update;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.persagy.adm.server.custom.dao.AdmQrCodeMapper;
import com.persagy.adm.server.custom.entity.db.AdmQrCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 检查二维码数据是否有更新
 */
@Component
@Slf4j
public class AdmQrCodeCheckUpdate implements CheckUpdate {
    @Autowired
    AdmQrCodeMapper qrCodeMapper;
    @Override
    public boolean doCheck(CheckUpdateContext hasUpdateReq) {
        log.info("开始检查二维码数据是否有更新");
        return qrCodeMapper.selectOne(new LambdaQueryWrapper<AdmQrCode>().select(AdmQrCode::getId).eq(AdmQrCode::getProjectId, hasUpdateReq.getProjectId()).gt(AdmQrCode::getTs, hasUpdateReq.getDownloadAdmTs()).last("limit 1")) != null;
    }
}
