â€feat: get_devicedict

This commit is contained in:
h7ml 2021-06-29 18:06:19 +08:00
parent 2a3c26e02f
commit 6159414e8e
No known key found for this signature in database
GPG Key ID: A37A4F13B34F2202
2 changed files with 42 additions and 6 deletions

View File

@ -190,6 +190,33 @@
"TOPO"
]
}
},
"/devicedict": {
"get": {
"description": "查询设备参数字典",
"parameters": [
{
"in": "query",
"name": "deviceid",
"required": true
}
],
"responses": {
"200": {
"description": "Returns instance data"
},
"404": {
"description": "object not found",
"schema": {
"$ref": "#/definitions/Error"
}
}
},
"summary": "查询设备参数字典",
"tags": [
"TOPO"
]
}
}
},
"tags": [
@ -198,4 +225,4 @@
"description": "云组态"
}
]
}
}

View File

@ -50,23 +50,23 @@ handle(OperationID, Args, Context, Req) ->
Headers = #{},
case catch do_request(OperationID, Args, Context, Req) of
{ErrType, Reason} when ErrType == 'EXIT'; ErrType == error ->
?LOG(info,"do request: ~p, ~p, ~p~n", [OperationID, Args, Reason]),
?LOG(info, "do request: ~p, ~p, ~p~n", [OperationID, Args, Reason]),
Err = case is_binary(Reason) of
true -> Reason;
false -> dgiot_utils:format("~p", [Reason])
end,
{500, Headers, #{<<"error">> => Err}};
ok ->
?LOG(debug,"do request: ~p, ~p ->ok ~n", [OperationID, Args]),
?LOG(debug, "do request: ~p, ~p ->ok ~n", [OperationID, Args]),
{200, Headers, #{}, Req};
{ok, Res} ->
?LOG(info,"do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
?LOG(info, "do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
{200, Headers, Res, Req};
{Status, Res} ->
?LOG(info,"do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
?LOG(info, "do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
{Status, Headers, Res, Req};
{Status, NewHeaders, Res} ->
?LOG(info,"do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
?LOG(info, "do request: ~p, ~p ->~p~n", [OperationID, Args, Res]),
{Status, maps:merge(Headers, NewHeaders), Res, Req}
end.
@ -124,6 +124,15 @@ do_request(post_dashboard, Arg, Context, _Req) ->
dgiot_dashboard:post_dashboard(Arg, Context),
{200, <<"success">>};
do_request(get_devicedict, #{<<"deviceid">> := Deviceid}, #{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
%% case dgiot_parse:get_object(<<"Device">>, <<"566cf263dc">>, [{"X-Parse-Session-Token", <<"r:e53794ae4bb367b13f73ddd5891e2755">>}], [{from, rest}]) of
case dgiot_parse:get_object(<<"Device">>, Deviceid, [{"X-Parse-Session-Token", SessionToken}], [{from, rest}]) of
{ok, #{<<"basedata">> := #{<<"deviceDict">> := DeviceDict}}} ->
{ok, DeviceDict};
_ ->
{error, []}
end;
%% API接口
do_request(_OperationId, _Args, _Context, _Req) ->