package com.caliverse.admin.Indicators.Indicatorsservice.base;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.stereotype.Service;

import com.caliverse.admin.global.common.constants.AdminConstants;

@Service
public abstract class IndicatorsLogLoadServiceBase implements IndicatorsLogLoadService {

    protected final MongoTemplate mongoTemplate;

    public IndicatorsLogLoadServiceBase(
            @Qualifier("mongoIndicatorTemplate") MongoTemplate mongoTemplate
    ) {
        this.mongoTemplate = mongoTemplate;
    }

    protected Criteria makeCriteria(String startDate, String endDate, String dateFieldName) {
        return new Criteria()
                .andOperator(
                        Criteria.where(dateFieldName).gte(startDate),
                        Criteria.where(dateFieldName).lte(endDate)
                );
    }

    public Criteria makeCriteria(String startDate, String endDate)
    {
        return makeCriteria(startDate, endDate, AdminConstants.MONGO_DB_KEY_LOGTIME);
    }

}

