mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-02 04:08:54 +08:00
fix: get_roleuser
This commit is contained in:
parent
06f447c673
commit
493d7bdb97
@ -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)};
|
||||
_ ->
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user