package com.jay.monitor.data.server.store.es;

import com.jay.monitor.data.core.enums.MsgTypeEnums;
import com.jay.monitor.data.server.models.entity.es.JayMonitorUrlIndex;
import com.jay.monitor.data.server.models.request.trace.URLRequest;
import com.jay.monitor.data.server.models.response.trace.URLTraceResponse;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class URLElasticSearchProcess
    extends AbstractTraceElasticSearch<URLRequest, URLTraceResponse, JayMonitorUrlIndex> {

    @Override
    public Class getIndexClass() {
        return JayMonitorUrlIndex.class;
    }

    @Override
    public MsgTypeEnums msgTypeEnums() {
        return MsgTypeEnums.URL;
    }

    @Override
    public List<URLTraceResponse> builderResponseList(List<JayMonitorUrlIndex> list) {
        List<URLTraceResponse> sqlTraceResponses = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                JayMonitorUrlIndex jayMonitorUrlIndex = list.get(i);
                URLTraceResponse urlTraceResponse = new URLTraceResponse();
                BeanUtils.copyProperties(jayMonitorUrlIndex, urlTraceResponse);
                sqlTraceResponses.add(urlTraceResponse);
            }
        }
        return sqlTraceResponses;
    }
}
