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

/**
 * 检查服务区域是否有数据更新
 */
@Component
@Slf4j
public class AdmServerAreaCheckUpdate implements CheckUpdate{
    @Autowired
    AdmServeAreaMapper serverAreaMapper;
    @Override
    public boolean doCheck(CheckUpdateContext hasUpdateReq) {
        log.info("开始检查检查服务区域是否有数据更新");
        return serverAreaMapper.selectOne(new LambdaQueryWrapper<AdmServeArea>().select(AdmServeArea::getId).eq(AdmServeArea::getProjectId, hasUpdateReq.getProjectId()).gt(AdmServeArea::getTs, hasUpdateReq.getDownloadAdmTs()).last("limit 1")) != null;
    }
}
