fix: get_roleuser

This commit is contained in:
jhonliu 2022-05-09 15:51:50 +08:00
parent 06f447c673
commit 493d7bdb97
3 changed files with 16 additions and 13 deletions

View File

@ -436,6 +436,7 @@ tree() ->
end, Acc1, maps:values(Value1))
end, Acc, maps:values(Value))
end, Tree, maps:values(Paths)),
%% [<<"Basic">>,],
NewMap = maps:from_list(lists:sort(maps:to_list(Tree1))),
{ok, maps:values(NewMap)};
_ ->

View File

@ -33,7 +33,7 @@
put_User_Role/3,
put_roleuser/2,
post_roleuser/2,
get_roleuser/3,
get_roleuser/2,
del_roleuser/2,
get_UserIds/1
]).
@ -270,8 +270,10 @@ refresh_session(Token) ->
}).
get_roleuser(Filter, IncludeChild, SessionToken) ->
case dgiot_parse:query_object(<<"_Role">>, Filter,
get_roleuser(Filter, SessionToken) ->
IncludeChild = maps:get(<<"include">>, Filter, false),
%% io:format("~s ~p Filter ~p IncludeChild ~p ~n", [?FILE, ?LINE, Filter, IncludeChild]),
case dgiot_parse:query_object(<<"_Role">>, maps:without([<<"include">>],Filter),
[{"X-Parse-Session-Token", SessionToken}], [{from, rest}]) of
{ok, #{<<"results">> := Roles}} ->
Users =
@ -288,15 +290,16 @@ get_roleuser(Filter, IncludeChild, SessionToken) ->
Acc2 ++ dgiot_parse_auth:get_UserIds(ChildRoleId)
end, [], ChildRoleIds),
UsersQuery =
#{<<"where">> => #{<<"objectId">> => #{<<"$in">> => UserIds}},
<<"keys">> => []
},
#{<<"where">> => #{<<"objectId">> => #{<<"$in">> => UserIds}}},
%% io:format("~s ~p ~p ~n", [?FILE, ?LINE, UsersQuery]),
case dgiot_parse:query_object(<<"_User">>, UsersQuery) of
{ok, #{<<"results">> := Results}} ->
Acc ++ lists:foldl(fun(X, Acc2) ->
Acc2 ++ [X#{<<"role">> => maps:with([<<"org_type">>, <<"tag">>, <<"depname">>], Role)}]
end, [], Results);
_ -> Acc
lists:foldl(fun
(X, Acc2) ->
Acc2 ++ [X#{<<"role">> => maps:with([<<"org_type">>, <<"tag">>, <<"depname">>], Role)}]
end, Acc, Results);
_ ->
Acc
end
end, [], Roles),
NewUsers =

View File

@ -204,9 +204,8 @@ do_request(post_logout, #{<<"sessionToken">> := SessionToken}, _Context, _Req)
%% RoleUser : :json文件导库
%% OperationId:get_roleuser
%% :GET /iotapi/roleuser
do_request(get_roleuser, #{<<"where">> := Where} = Filter, #{<<"sessionToken">> := SessionToken} = Context, _Req0) ->
IncludeChild = maps:get(<<"include">>, Context, false),
dgiot_parse_auth:get_roleuser(Filter#{<<"where">> => jsx:decode(Where, [return_maps])}, IncludeChild, SessionToken);
do_request(get_roleuser, #{<<"where">> := Where} = Filter, #{<<"sessionToken">> := SessionToken} = _Context, _Req0) ->
dgiot_parse_auth:get_roleuser(Filter#{<<"where">> => jsx:decode(Where, [return_maps])}, SessionToken);
%% Role模版 : :json文件导库
%% OperationId:put_roleuser