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

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