package com.sckw.slope.detection.consumer.mqApi;

import com.sckw.core.web.response.HttpResult;
import com.sckw.log.TraceLog.TraceLog;
import com.sckw.slope.detection.consumer.AbstractHandler;
import com.sckw.slope.detection.consumer.HandlerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lfdc
 * @description
 * @date 2023-11-15 17:11:26
 */
@Service
public class MqttApiHandler {

    @Autowired
    HandlerFactory handlerFactory;

    @TraceLog(description = "mqtt消费")
    public HttpResult handle(String topic, String payload) {
        try {
            AbstractHandler handler = handlerFactory.getHandler(topic);
            return handler.handle(topic,payload);
        } catch (Exception e) {
            return HttpResult.error("MQTT回执类型错误");
        }
    }
}
