mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-02 04:08:54 +08:00
feat(iotapi): query relation
This commit is contained in:
parent
e435472a14
commit
bf5e980500
1
.gitignore
vendored
1
.gitignore
vendored
@ -59,6 +59,7 @@ ci.sh
|
||||
node_modules/
|
||||
apps/emqx_*
|
||||
apps/dgiot_parse/etc/dgiot_parse.conf
|
||||
*/dgiot_parse_temp.conf
|
||||
apps/dgiot_jieshun/
|
||||
apps/dgiot_mingcheng/
|
||||
apps/dgiot_xinchuangwei/
|
||||
|
@ -909,6 +909,61 @@
|
||||
"Data"
|
||||
]
|
||||
},
|
||||
"get": {
|
||||
"summary": "查询关联",
|
||||
"description": "查询关联",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "destClass",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"example": "_Role",
|
||||
"default": "_Role",
|
||||
"description": "目标类名"
|
||||
},
|
||||
{
|
||||
"name": "destId",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"example": "ccf5456562",
|
||||
"default": "ccf5456562",
|
||||
"description": "目标类对象"
|
||||
},
|
||||
{
|
||||
"name": "destField",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"example": "views",
|
||||
"default": "views",
|
||||
"description": "目标关联字段"
|
||||
},
|
||||
{
|
||||
"name": "srcClass",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"example": "View",
|
||||
"default": "View",
|
||||
"description": "源类名"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Returns success"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Data"
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"summary": "删除关联",
|
||||
"description": "删除关联",
|
||||
|
@ -138,21 +138,21 @@ do_request(post_upload_token, #{<<"from">> := <<"fastdfs">>}, _Context, Req0) ->
|
||||
%% OperationId:get_thing
|
||||
%% 请求:GET /iotapi/get_thing
|
||||
do_request(get_thing, #{<<"productid">> := ProductId, <<"moduleType">> := ModuleType},
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
getThing(ProductId, ModuleType, SessionToken);
|
||||
|
||||
%% Thing 概要: 导库 描述:添加物模型
|
||||
%% OperationId:post_thing
|
||||
%% 请求:PUT /iotapi/post_thing
|
||||
do_request(post_thing, #{<<"productid">> := ProductId, <<"item">> := Item} = _Body,
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
postThing(ProductId, Item, SessionToken);
|
||||
|
||||
%% Thing 概要: 导库 描述:修改物模型
|
||||
%% OperationId:put_thing
|
||||
%% 请求:PUT /iotapi/put_thing
|
||||
do_request(put_thing, #{<<"productid">> := ProductId, <<"item">> := Item} = _Body,
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
putTing(ProductId, Item, SessionToken);
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ do_request(put_thing, #{<<"productid">> := ProductId, <<"item">> := Item} = _Bod
|
||||
%% OperationId:put_thing
|
||||
%% 请求:PUT /iotapi/put_thing
|
||||
do_request(delete_thing, #{<<"productid">> := ProductId, <<"item">> := Item} = _Body,
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
deleteThing(ProductId, SessionToken, Item);
|
||||
|
||||
|
||||
@ -168,7 +168,7 @@ do_request(delete_thing, #{<<"productid">> := ProductId, <<"item">> := Item} = _
|
||||
%% OperationId:post_product
|
||||
%% 请求:POST /iotapi/post_product
|
||||
do_request(post_product, #{<<"file">> := FileInfo, <<"appid">> := Appid} = _Body,
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
case maps:get(<<"contentType">>, FileInfo, <<"unknow">>) of
|
||||
<<"application/x-zip-compressed">> -> post_product(FileInfo, Appid, SessionToken);
|
||||
<<"application/zip">> -> post_product(FileInfo, Appid, SessionToken);
|
||||
@ -371,7 +371,7 @@ do_request(post_import_file, #{<<"path">> := Path}, #{<<"sessionToken">> := Sess
|
||||
%% OperationId:post_menus
|
||||
%% 请求:POST /iotapi/post_menu
|
||||
do_request(post_menu, #{<<"file">> := FileInfo} = _Body,
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
#{<<"sessionToken">> := SessionToken} = _Context, _Req) ->
|
||||
?LOG(info, "FileInfo ~p", [FileInfo]),
|
||||
case maps:get(<<"contentType">>, FileInfo, <<"unknow">>) of
|
||||
<<"application/x-zip-compressed">> -> post_menu(FileInfo, SessionToken);
|
||||
@ -400,6 +400,30 @@ do_request(post_relation, #{<<"destClass">> := DestClass, <<"destId">> := DestId
|
||||
},
|
||||
dgiot_parse:update_object(DestClass, DestId, Map);
|
||||
|
||||
|
||||
%% Relation 概要: 查询关系 描述:json文件导库
|
||||
%% OperationId:get_relation
|
||||
%% 请求:get /iotapi/relation
|
||||
do_request(get_relation, #{<<"destClass">> := DestClass, <<"destId">> := DestId, <<"destField">> := DestField, <<"srcClass">> := SrcClass} = _Args, _Context, _Req) ->
|
||||
io:format("~s ~p ~p ~n", [?FILE, ?LINE, _Args]),
|
||||
Where = #{
|
||||
<<"where">> => #{
|
||||
<<"$relatedTo">> => #{
|
||||
<<"object">> => #{
|
||||
<<"__type">> => <<"Pointer">>,
|
||||
<<"className">> => DestClass,
|
||||
<<"objectId">> => DestId
|
||||
},
|
||||
<<"key">> => DestField
|
||||
}
|
||||
},
|
||||
<<"order">> => <<"-updatedAt">>,
|
||||
<<"count">> => 1
|
||||
},
|
||||
io:format("~s ~p ~p ~n", [?FILE, ?LINE, Where]),
|
||||
dgiot_parse:query_object(SrcClass, Where);
|
||||
|
||||
|
||||
%% Relation 概要: 删除关系 描述:json文件导库
|
||||
%% OperationId:post_relation
|
||||
%% 请求:DELETE /iotapi/relation
|
||||
|
@ -7,12 +7,12 @@ parse.default_user = root,admin, dgiot_dev,dgiot_admin,guest
|
||||
##--------------------------------------------------------------------
|
||||
## parse config
|
||||
##--------------------------------------------------------------------
|
||||
parse.parse_server = http://prod.iotn2n.com:1337
|
||||
parse.parse_server = http://121.5.171.21:1337
|
||||
parse.parse_path = /parse/
|
||||
parse.parse_appid = d3300b6f53d7ee7da766142f2f7050eb
|
||||
parse.parse_master_key = 3d9707db9414c4e398c5036ddb1b2b62
|
||||
parse.parse_js_key = fc8f19e9dcc4b8b7848aed1f8dcda317
|
||||
parse.parse_rest_key = 7957b8a5923c8be145b317521b922b18
|
||||
parse.parse_appid = c73e0a99f70ee833f484705ea915d264
|
||||
parse.parse_master_key = 1fb04beba432da023507955baef040d7
|
||||
parse.parse_js_key = 80ba347026262c8910a3c2307bc175de
|
||||
parse.parse_rest_key = b242a85b9364657af6fc27ee5a90f748
|
||||
|
||||
##--------------------------------------------------------------------
|
||||
## parse cache
|
||||
@ -24,4 +24,4 @@ parse.cache.max_size = 100000
|
||||
## max_memory 最大内存数,单位byte
|
||||
parse.cache.max_memory = 1024000
|
||||
## max_time 最大时间间隔,单位秒
|
||||
parse.cache.max_time = 60
|
||||
parse.cache.max_time = 60
|
||||
|
27
apps/dgiot_parse/etc/dgiot_parse_temp.conf
Normal file
27
apps/dgiot_parse/etc/dgiot_parse_temp.conf
Normal file
@ -0,0 +1,27 @@
|
||||
##--------------------------------------------------------------------
|
||||
## delete field
|
||||
##--------------------------------------------------------------------
|
||||
parse.delete_field = ACL,objectId,updatedAt,createdAt
|
||||
parse.default_user = root,admin, dgiot_dev,dgiot_admin,guest
|
||||
|
||||
##--------------------------------------------------------------------
|
||||
## parse config
|
||||
##--------------------------------------------------------------------
|
||||
parse.parse_server = http://prod.iotn2n.com:1337
|
||||
parse.parse_path = /parse/
|
||||
parse.parse_appid = d3300b6f53d7ee7da766142f2f7050eb
|
||||
parse.parse_master_key = 3d9707db9414c4e398c5036ddb1b2b62
|
||||
parse.parse_js_key = fc8f19e9dcc4b8b7848aed1f8dcda317
|
||||
parse.parse_rest_key = 7957b8a5923c8be145b317521b922b18
|
||||
|
||||
##--------------------------------------------------------------------
|
||||
## parse cache
|
||||
##--------------------------------------------------------------------
|
||||
## auto_save自动坚持保存时间 单位 毫秒
|
||||
parse.cache.auto_save = 10000
|
||||
## max_size 最大存储数量
|
||||
parse.cache.max_size = 100000
|
||||
## max_memory 最大内存数,单位byte
|
||||
parse.cache.max_memory = 1024000
|
||||
## max_time 最大时间间隔,单位秒
|
||||
parse.cache.max_time = 60
|
Loading…
Reference in New Issue
Block a user