mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-01 19:58:46 +08:00
âfeat: get_devicedict
This commit is contained in:
parent
2a3c26e02f
commit
6159414e8e
@ -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": "云组态"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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) ->
|
||||
|
Loading…
Reference in New Issue
Block a user