Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dgiot/dgiot
Browse files Browse the repository at this point in the history
  • Loading branch information
h7ml committed Jun 24, 2021
2 parents 9420101 + 9fd4d89 commit 2712e7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
12 changes: 1 addition & 11 deletions apps/dgiot_bridge/priv/swagger/swagger_rule.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
]
},
"put": {
"security": [],
"summary": "修改规则引擎",
"description": "修改规则引擎",
"parameters": [
Expand All @@ -331,14 +330,14 @@
"type": "string"
},
{
"in": "body",
"name": "params",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateRule"
},
"description": "规则引擎内容参数",
"type": "object"
}
],
"responses": {
Expand Down Expand Up @@ -379,7 +378,6 @@
},
"/provider": {
"get": {
"security": [],
"summary": "获取acl编辑器提示语",
"description": "获取acl编辑器提示语",
"parameters": [
Expand Down Expand Up @@ -430,7 +428,6 @@
},
"/rules": {
"get": {
"security": [],
"summary": "获取规则引擎列表",
"description": "获取规则引擎列表",
"parameters": [
Expand Down Expand Up @@ -471,7 +468,6 @@
]
},
"post": {
"security": [],
"summary": "创建规则引擎",
"description": "创建规则引擎",
"parameters": [
Expand Down Expand Up @@ -508,7 +504,6 @@
},
"/actions": {
"get": {
"security": [],
"summary": "获取动作列表",
"description": "获取动作列表",
"parameters": [
Expand Down Expand Up @@ -551,7 +546,6 @@
},
"/actions/{id}": {
"get": {
"security": [],
"summary": "获取动作",
"description": "获取动作",
"parameters": [
Expand Down Expand Up @@ -601,7 +595,6 @@
},
"/resources": {
"get": {
"security": [],
"summary": "获取资源列表",
"description": "获取资源列表",
"parameters": [
Expand Down Expand Up @@ -642,7 +635,6 @@
]
},
"post": {
"security": [],
"summary": "创建资源",
"description": "创建资源",
"parameters": [
Expand Down Expand Up @@ -679,7 +671,6 @@
},
"/resources/{id}": {
"get": {
"security": [],
"summary": "获取资源",
"description": "获取资源",
"parameters": [
Expand Down Expand Up @@ -777,7 +768,6 @@
},
"/resource_types": {
"get": {
"security": [],
"summary": "获取资源类型列表",
"description": "获取资源类型列表",
"parameters": [
Expand Down
18 changes: 6 additions & 12 deletions apps/dgiot_bridge/src/handler/dgiot_rule_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ do_request(get_provider, #{<<"language">> := Language}, _Context, _Req) ->


%% Rule 概要: 获取规则引擎 描述:获取规则引擎
%% OperationId:get_rules_id
%% OperationId:get_rule_id
%% 请求:GET /iotapi/rule/:{id}
do_request(get_rule_id, #{<<"id">> := RuleID}, _Context, _Req) ->
emqx_rule_engine_api:show_rule(#{id => RuleID}, []);
Expand All @@ -96,18 +96,12 @@ do_request(get_rule_id, #{<<"id">> := RuleID}, _Context, _Req) ->
%% Rule 概要: 修改规则引擎 描述:修改规则引擎
%% OperationId:put_rules_id
%% 请求:PUT /iotapi/rule/:{id}
%%do_request(put_rule_id, Params, _Context, _Req) ->
%% ?LOG(info, "Params ~p ", [Params]),
%% {error, <<"Not Allowed.">>};
%% emqx_rule_engine_api:update_rule(#{id => RuleID}, maps:to_list(Params));

do_request(put_rule_id, #{<<"id">> := RuleID, <<"params">> := Params}, _Context, _Req) ->
?LOG(info, "Params ~p ", [Params]),
emqx_rule_engine_api:update_rule(#{id => RuleID}, maps:to_list(Params));
do_request(put_rule_id, #{<<"id">> := RuleID} = Params, _Context, _Req) ->
emqx_rule_engine_api:update_rule(#{id => RuleID}, maps:to_list(maps:without([<<"id">>],Params)));

%% Rule 概要: 删除规则引擎 描述:删除规则引擎
%% OperationId:delete_rules_id
%% 请求:DELETE /iotapi/rules/:{id}
%% OperationId:delete_rule_id
%% 请求:DELETE /iotapi/rule/:{id}
do_request(delete_rule_id, #{<<"id">> := RuleID}, _Context, _Req) ->
emqx_rule_engine_api:delete_rule(#{id => RuleID}, []);

Expand Down Expand Up @@ -210,7 +204,7 @@ do_request(_OperationId, _Args, _Context, _Req) ->
get_channel() ->
case dgiot_parse:query_object(<<"Channel">>, #{<<"keys">> => [<<"name">>]}) of
{ok, #{<<"results">> := Results}} when length(Results) > 0 ->
lists:foldl(fun(#{<<"objectId">> := ChannelId, <<"name">> := Name}, Acc) ->
lists:foldl(fun(#{<<"objectId">> := ChannelId,<<"name">> := Name}, Acc) ->
Acc ++ [#{
<<"config">> => #{<<"channel">> => ChannelId},
<<"description">> => Name,
Expand Down

0 comments on commit 2712e7b

Please sign in to comment.