This commit is contained in:
anlicheng 2025-08-12 17:03:28 +08:00
parent 138ce5c20a
commit 87c3e46289
2 changed files with 6 additions and 4 deletions

View File

@ -13,11 +13,11 @@
%% API
-export([get_all_endpoints/0, get_endpoint_by_id/1]).
-spec get_all_endpoints() -> EndpointIds :: [integer()].
-spec get_all_endpoints() -> [Endpoint :: map()].
get_all_endpoints() ->
case mysql_pool:get_all(mysql_iot, <<"SELECT id FROM endpoint where status = 1">>) of
case mysql_pool:get_all(mysql_iot, <<"SELECT * FROM endpoint where status = 1">>) of
{ok, Endpoints} ->
lists:map(fun(#{<<"id">> := Id}) -> Id end, Endpoints);
Endpoints;
{error, _} ->
[]
end.

View File

@ -29,7 +29,9 @@ start_link() ->
%% modules => modules()} % optional
init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
ChildSpecs = [],
{ok, Endpoints} = endpoint_bo:get_all_endpoints(),
ChildSpecs = lists:map(fun child_spec/1, Endpoints),
{ok, {SupFlags, ChildSpecs}}.
%% internal functions