feat: menu.json

This commit is contained in:
Evan You 2022-05-17 21:19:42 +08:00
parent dbf3a2a2e8
commit 32314dd111
3 changed files with 1917 additions and 11 deletions

View File

@ -128,7 +128,7 @@ get_control(ProductId) ->
end.
update_properties(ProductId, Product) ->
io:format("~s ~p ProductId = ~p.~n", [?FILE, ?LINE, ProductId]),
%% io:format("~s ~p ProductId = ~p.~n", [?FILE, ?LINE, ProductId]),
PropertiesTpl = dgiot_dlink:get_json(<<"properties_tpl">>),
case dgiot_product:lookup_prod(ProductId) of
{ok, #{<<"thing">> := #{<<"properties">> := Props} = Thing}} ->
@ -141,8 +141,7 @@ update_properties(ProductId, Product) ->
NewThing = Thing#{
<<"properties">> => NewProperties
},
Message = dgiot_parse:update_object(<<"Product">>, ProductId, #{<<"thing">> => NewThing}),
io:format("~s ~p Message = ~p.~n", [?FILE, ?LINE, Message]),
dgiot_parse:update_object(<<"Product">>, ProductId, #{<<"thing">> => NewThing}),
dgiot_data:insert(?DGIOT_PRODUCT, ProductId, Product#{<<"thing">> => NewThing});
_Error ->
[]

File diff suppressed because it is too large Load Diff

View File

@ -88,7 +88,19 @@ do_request(get_protocol, _Body, _Context, _Req) ->
%% OperationId:dlinkjson
%% :GET /iotapi/dlinkjson
do_request(get_dlinkjson, #{<<"type">> := <<"swaggerTree">>}, _Context, _Req) ->
{ok, SwaggerTree} = dgiot_swagger:tree(),
{ok, Swagger} = dgiot_swagger:tree(),
{file, Here} = code:is_loaded(?MODULE),
Dir = filename:dirname(filename:dirname(Here)),
FileName = <<"swagger.json">>,
SwaggerFile = dgiot_httpc:url_join([Dir, "/priv/json/", dgiot_utils:to_list(FileName)]),
case dgiot_data:get(swaggerTree) of
not_find ->
file:write_file(SwaggerFile, jsx:encode(Swagger)),
dgiot_data:insert(swaggerTree, <<"swaggerTree">>);
_ ->
pass
end,
SwaggerTree = dgiot_dlink:get_json(<<"swaggerTree">>),
{200, SwaggerTree};
do_request(get_dlinkjson, #{<<"type">> := <<"Table">>}, _Context, _Req) ->