1
- use bios_basic:: rbum:: dto:: rbum_filer_dto:: { RbumBasicFilterReq , RbumItemRelFilterReq , RbumSetCateFilterReq , RbumSetItemRelFilterReq } ;
1
+ use bios_basic:: rbum:: dto:: rbum_filer_dto:: { RbumBasicFilterReq , RbumCertFilterReq , RbumItemRelFilterReq , RbumSetCateFilterReq , RbumSetItemRelFilterReq } ;
2
2
use bios_basic:: rbum:: rbum_enumeration:: RbumRelFromKind ;
3
3
use tardis:: web:: context_extractor:: TardisContextExtractor ;
4
4
use tardis:: web:: poem_openapi;
5
5
use tardis:: web:: poem_openapi:: { param:: Path , param:: Query } ;
6
6
use tardis:: web:: web_resp:: { TardisApiResult , TardisPage , TardisResp } ;
7
7
use tardis:: TardisFuns ;
8
8
9
- use crate :: basic:: dto:: iam_account_dto:: { IamAccountDetailAggResp , IamAccountSummaryAggResp } ;
9
+ use crate :: basic:: dto:: iam_account_dto:: { IamAccountDetailAggResp , IamAccountDetailResp , IamAccountSummaryAggResp } ;
10
10
use crate :: basic:: dto:: iam_filer_dto:: IamAccountFilterReq ;
11
11
use crate :: basic:: serv:: iam_account_serv:: IamAccountServ ;
12
12
use crate :: basic:: serv:: iam_cert_serv:: IamCertServ ;
@@ -15,7 +15,11 @@ use crate::basic::serv::iam_set_serv::IamSetServ;
15
15
use crate :: iam_constants;
16
16
use crate :: iam_enumeration:: IamRelKind ;
17
17
use bios_basic:: helper:: request_helper:: add_remote_ip;
18
+ use bios_basic:: rbum:: serv:: rbum_cert_serv:: RbumCertServ ;
19
+ use bios_basic:: rbum:: serv:: rbum_crud_serv:: RbumCrudOperation ;
20
+ use bios_basic:: rbum:: serv:: rbum_item_serv:: RbumItemCrudOperation ;
18
21
use tardis:: web:: poem:: Request ;
22
+
19
23
#[ derive( Clone , Default ) ]
20
24
pub struct IamCiAccountApi ;
21
25
@@ -117,7 +121,7 @@ impl IamCiAccountApi {
117
121
TardisResp :: ok ( TardisFuns :: crypto. base64 . encode ( TardisFuns :: json. obj_to_string ( & ctx_resp) . unwrap_or_default ( ) ) )
118
122
}
119
123
120
- //// Get Account By Account Id 通过帐户Id获取帐户
124
+ /// Get Account By Account Id 通过帐户Id获取帐户
121
125
#[ oai( path = "/:id" , method = "get" ) ]
122
126
async fn get ( & self , id : Path < String > , tenant_id : Query < Option < String > > , ctx : TardisContextExtractor , request : & Request ) -> TardisApiResult < IamAccountDetailAggResp > {
123
127
let ctx = IamCertServ :: try_use_tenant_ctx ( ctx. 0 , tenant_id. 0 ) ?;
@@ -141,4 +145,62 @@ impl IamCiAccountApi {
141
145
ctx. execute_task ( ) . await ?;
142
146
TardisResp :: ok ( result)
143
147
}
148
+
149
+ /// Find Account Id By Ak
150
+ ///
151
+ /// if kind is none,query default kind(UserPwd)
152
+ #[ oai( path = "/:ak/ak" , method = "get" ) ]
153
+ async fn find_account_by_ak (
154
+ & self ,
155
+ ak : Path < String > ,
156
+ kind : Query < Option < String > > ,
157
+ tenant_id : Query < Option < String > > ,
158
+ supplier : Query < Option < String > > ,
159
+ ctx : TardisContextExtractor ,
160
+ request : & Request ,
161
+ ) -> TardisApiResult < Option < IamAccountDetailResp > > {
162
+ add_remote_ip ( request, & ctx. 0 ) . await ?;
163
+ let funs = iam_constants:: get_tardis_inst ( ) ;
164
+ let supplier = supplier. 0 . unwrap_or_default ( ) ;
165
+ let kind = kind. 0 . unwrap_or_else ( || "UserPwd" . to_string ( ) ) ;
166
+ let kind = if kind. is_empty ( ) { "UserPwd" . to_string ( ) } else { kind } ;
167
+
168
+ let result = if let Ok ( conf_id) = IamCertServ :: get_cert_conf_id_by_kind_supplier ( & kind, & supplier. clone ( ) , tenant_id. 0 , & funs) . await {
169
+ if let Some ( cert) = RbumCertServ :: find_one_detail_rbum (
170
+ & RbumCertFilterReq {
171
+ ak : Some ( ak. 0 ) ,
172
+ rel_rbum_cert_conf_ids : Some ( vec ! [ conf_id] ) ,
173
+ ..Default :: default ( )
174
+ } ,
175
+ & funs,
176
+ & ctx. 0 ,
177
+ )
178
+ . await ?
179
+ {
180
+ Some (
181
+ IamAccountServ :: get_item (
182
+ & cert. owner ,
183
+ & IamAccountFilterReq {
184
+ basic : RbumBasicFilterReq {
185
+ own_paths : Some ( "" . to_string ( ) ) ,
186
+ with_sub_own_paths : true ,
187
+ ..Default :: default ( )
188
+ } ,
189
+ ..Default :: default ( )
190
+ } ,
191
+ & funs,
192
+ & ctx. 0 ,
193
+ )
194
+ . await ?,
195
+ )
196
+ } else {
197
+ None
198
+ }
199
+ } else {
200
+ None
201
+ } ;
202
+
203
+ ctx. 0 . execute_task ( ) . await ?;
204
+ TardisResp :: ok ( result)
205
+ }
144
206
}
0 commit comments