From 87c3e46289863f3dfe33199097caf763206f4ed8 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 12 Aug 2025 17:03:28 +0800 Subject: [PATCH] fix --- apps/iot/src/{database => endpoint}/endpoint_bo.erl | 6 +++--- apps/iot/src/iot_endpoint_sup.erl | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) rename apps/iot/src/{database => endpoint}/endpoint_bo.erl (76%) diff --git a/apps/iot/src/database/endpoint_bo.erl b/apps/iot/src/endpoint/endpoint_bo.erl similarity index 76% rename from apps/iot/src/database/endpoint_bo.erl rename to apps/iot/src/endpoint/endpoint_bo.erl index 831d4d4..843afa3 100644 --- a/apps/iot/src/database/endpoint_bo.erl +++ b/apps/iot/src/endpoint/endpoint_bo.erl @@ -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. diff --git a/apps/iot/src/iot_endpoint_sup.erl b/apps/iot/src/iot_endpoint_sup.erl index 766fc54..671a24f 100644 --- a/apps/iot/src/iot_endpoint_sup.erl +++ b/apps/iot/src/iot_endpoint_sup.erl @@ -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