feat(iotapi): query relation

This commit is contained in:
h7ml 2022-05-11 16:22:04 +08:00
parent e435472a14
commit bf5e980500
5 changed files with 119 additions and 12 deletions

1
.gitignore vendored
View File

@ -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/

View File

@ -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": "删除关联",

View File

@ -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

View File

@ -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

View 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