add tests

This commit is contained in:
anlicheng 2025-04-28 14:51:11 +08:00
parent 5f66983633
commit 490894620b

View File

@ -12,6 +12,7 @@
%% API
-export([route_uuid/3]).
-export([set_tests/1]).
-spec route_uuid(RouterUUID :: binary(), EventType :: integer(), Params :: map()) -> no_return().
route_uuid(RouterUUID, EventType, Params) when is_binary(RouterUUID), is_integer(EventType), is_map(Params) ->
@ -21,10 +22,19 @@ route_uuid(RouterUUID, EventType, Params) when is_binary(RouterUUID), is_integer
lager:debug("[iot_ai_router] hget uuid: ~p, location_code: ~p", [RouterUUID, LocationCode]),
%% 2024-12-02, 2
lists:member(EventType, [15]) andalso iot_donghuoliren_endpoint:forward(LocationCode, DynamicLocationCode, EventType, Params),
%% 2024-03-21
TestEventTypes = application:get_env(iot, test_event_types, []),
case lists:member(EventType, TestEventTypes) of
true ->
lager:debug("[iot_ai_router] event_type: ~p, is test", [EventType]);
false ->
iot_jinzhi_endpoint:forward(LocationCode, DynamicLocationCode, EventType, Params);
end;
{ok, _} ->
lager:debug("[iot_ai_router] hget location_code, uuid: ~p, not found", [RouterUUID]);
{error, Reason} ->
lager:debug("[iot_ai_router] hget location_code uuid: ~p, get error: ~p", [RouterUUID, Reason])
end.
set_tests(TestEventTypes) when is_list(TestEventTypes) ->
application:set_env(iot, test_event_types, TestEventTypes).