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.AdmCadMapper;
import com.persagy.adm.server.custom.entity.db.AdmCad;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 检查CAD图纸数据有无更新
 */
@Component
@Slf4j
public class AdmCadCheckUpdate implements CheckUpdate{
    @Autowired
    AdmCadMapper admCadMapper;
    @Override
    public boolean doCheck(CheckUpdateContext hasUpdateReq) {
        log.info("开始检查CAD图纸是否有更新");
        return admCadMapper.selectOne(new LambdaQueryWrapper<AdmCad>().select(AdmCad::getId).eq(AdmCad::getProjectId, hasUpdateReq.getProjectId()).gt(AdmCad::getTs, hasUpdateReq.getDownloadAdmTs()).last("limit 1")) != null;
    }
}
