%%%-------------------------------------------------------------------
%%% @author aresei
%%% @copyright (C) 2023, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 16. 5月 2023 12:48
%%%-------------------------------------------------------------------
-module(ai_event_logs_bo).
-author("aresei").
-include("iot.hrl").

-export([insert/6]).

%% API

-spec insert(HostUUID :: binary(), DeviceUUID :: binary(), SceneId :: integer(), MicroId :: integer(), EventType :: integer(), Content :: binary()) ->
    ok | {ok, InsertId :: integer()} | {error, Reason :: any()}.
insert(HostUUID, DeviceUUID, SceneId, MicroId, EventType, Content)
    when is_integer(EventType), is_binary(HostUUID), is_binary(DeviceUUID), is_integer(SceneId), is_integer(MicroId), is_binary(Content) ->

    mysql_pool:insert(mysql_iot, <<"ai_event_logs">>, #{
        <<"event_type">> => EventType,
        <<"host_uuid">> => HostUUID,
        <<"device_uuid">> => DeviceUUID,
        <<"scene_id">> => SceneId,
        <<"micro_id">> => MicroId,
        <<"content">> => Content,
        <<"created_at">> => calendar:local_time()
    }, true).