@@ -29,27 +29,75 @@ export class BindingList extends AbstractController<RequestType, ResponseType> {
2929 } ;
3030
3131 public async execute ( ) : Promise < Response < ResponseType > > {
32- const result = { } as Record < Lowercase < LoginPlatform > , boolean > ;
32+ const result = { meta : { } } as ResponseType ;
3333
34- await Promise . all (
35- Object . keys ( this . svc ) . map ( svc => {
36- return this . svc [ svc as LoginPlatform ] . exist ( ) . then ( exist => {
37- result [ svc . toLowerCase ( ) as Lowercase < LoginPlatform > ] = exist ;
38- } ) ;
39- } ) ,
40- ) ;
34+ this . svc [ LoginPlatform . WeChat ] . name ( ) ;
35+
36+ await Promise . all ( [
37+ this . listWeChat ( result ) ,
38+ this . listPhone ( result ) ,
39+ this . listAgora ( result ) ,
40+ this . listApple ( result ) ,
41+ this . listGithub ( result ) ,
42+ this . listGoogle ( result ) ,
43+ this . listEmail ( result ) ,
44+ ] ) ;
4145
4246 return {
4347 status : Status . Success ,
4448 data : result ,
4549 } ;
4650 }
4751
52+ private async listWeChat ( result : ResponseType ) : Promise < void > {
53+ const name = await this . svc [ LoginPlatform . WeChat ] . name ( ) ;
54+ result . wechat = name !== null ;
55+ result . meta . wechat = name || "" ;
56+ }
57+
58+ private async listPhone ( result : ResponseType ) : Promise < void > {
59+ const phone = await this . svc [ LoginPlatform . Phone ] . phoneNumber ( ) ;
60+ result . phone = phone !== null ;
61+ result . meta . phone = phone || "" ;
62+ }
63+
64+ private async listAgora ( result : ResponseType ) : Promise < void > {
65+ const agora = await this . svc [ LoginPlatform . Agora ] . name ( ) ;
66+ result . agora = agora !== null ;
67+ result . meta . agora = agora || "" ;
68+ }
69+
70+ private async listApple ( result : ResponseType ) : Promise < void > {
71+ const agora = await this . svc [ LoginPlatform . Apple ] . name ( ) ;
72+ result . agora = agora !== null ;
73+ result . meta . agora = agora || "" ;
74+ }
75+
76+ private async listGithub ( result : ResponseType ) : Promise < void > {
77+ const github = await this . svc [ LoginPlatform . Github ] . name ( ) ;
78+ result . github = github !== null ;
79+ result . meta . github = github || "" ;
80+ }
81+
82+ private async listGoogle ( result : ResponseType ) : Promise < void > {
83+ const google = await this . svc [ LoginPlatform . Google ] . name ( ) ;
84+ result . google = google !== null ;
85+ result . meta . google = google || "" ;
86+ }
87+
88+ private async listEmail ( result : ResponseType ) : Promise < void > {
89+ const email = await this . svc [ LoginPlatform . Email ] . email ( ) ;
90+ result . email = email !== null ;
91+ result . meta . email = email || "" ;
92+ }
93+
4894 public errorHandler ( error : Error ) : ResponseError {
4995 return this . autoHandlerError ( error ) ;
5096 }
5197}
5298
5399interface RequestType { }
54100
55- type ResponseType = Record < Lowercase < LoginPlatform > , boolean > ;
101+ type ResponseType = Record < Lowercase < LoginPlatform > , boolean > & {
102+ meta : Record < Lowercase < LoginPlatform > , string > ;
103+ } ;
0 commit comments