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

import com.jay.monitor.data.core.enums.MsgTypeEnums;
import com.jay.monitor.data.server.models.entity.JayMonitorMq;
import com.jay.monitor.data.server.models.request.trace.MQRequest;
import com.jay.monitor.data.server.models.response.trace.MQTraceResponse;
import org.springframework.beans.BeanUtils;

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

public class MysqlMQSearchProcess extends AbstractMysqlSearchProcess<JayMonitorMq, MQRequest, MQTraceResponse> {

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

    @Override
    public List<MQTraceResponse> builderResponse(List<JayMonitorMq> query) throws Exception {
        List<MQTraceResponse> responseList = new ArrayList<>();
        for (int i = 0; i < query.size(); i++) {
            JayMonitorMq jayMonitorMq = query.get(i);
            MQTraceResponse mqTraceResponse = new MQTraceResponse();
            BeanUtils.copyProperties(jayMonitorMq, mqTraceResponse);
            responseList.add(mqTraceResponse);
        }
        return responseList;
    }

    @Override
    public JayMonitorMq builderQuery(MQRequest query) throws Exception {
        JayMonitorMq jayMonitorMq = new JayMonitorMq();
        BeanUtils.copyProperties(query, jayMonitorMq);
        return jayMonitorMq;
    }

}
