import { Application , IBoot } from 'egg' ; import { ApiConfig , ApiConfigKit , QyApiConfigKit , WxPayApiConfig , WxPayApiConifgKit } from 'tnwx' ; /**
 * 参考 https://eggjs.org/zh-cn/basics/app-start.html
 */ export default class FooBoot implements IBoot { private readonly app : Application ; constructor ( app ) { this . app = app ; } configWillLoad ( ) { } configDidLoad ( ) { this . app . logger . info ( 'configDidLoad...' ) ; } async didLoad ( ) { this . app . logger . info ( 'didLoad...' ) ; } async willReady ( ) { this . app . logger . info ( 'willReady...' ) ; } async didReady ( ) { this . app . logger . info ( 'didReady...' ) ; let config = this . app . config ; let devApiConfig = new ApiConfig ( config . devApiConfig . appId , config . devApiConfig . appScrect , config . devApiConfig . token ) ; let miniApiConfig = new ApiConfig ( config . miniApiConfig . appId , config . miniApiConfig . appScrect ) ; let openMpApiConfig = new ApiConfig ( config . openMpConfig . appId , config . openMpConfig . appScrect , config . openMpConfig . token , config . openMpConfig . encryptMessage , config . openMpConfig . encodingAesKey ) ; let qyApiConfig = new ApiConfig ( config . qyApiConfig . appId , config . qyApiConfig . appScrect , config . qyApiConfig . token , config . qyApiConfig . encryptMessage , config . qyApiConfig . encodingAesKey , config . qyApiConfig . corpId ) ; let qyMiniApiConfig = new ApiConfig ( config . qyMiniApiConfig . appId , config . qyMiniApiConfig . appScrect , config . qyMiniApiConfig . token , config . qyMiniApiConfig . encryptMessage , config . qyMiniApiConfig . encodingAesKey , config . qyMiniApiConfig . corpId ) ; let openCpConfig = new ApiConfig ( config . openCpConfig . appId , config . openCpConfig . appScrect , config . openCpConfig . token , config . openCpConfig . encryptMessage , config . openCpConfig . encodingAesKey , config . openCpConfig . corpId ) ; let openSuiteConfig = new ApiConfig ( config . openSuiteConfig . appId , config . openSuiteConfig . appScrect , config . openSuiteConfig . token , config . openSuiteConfig . encryptMessage , config . openSuiteConfig . encodingAesKey , config . openSuiteConfig . corpId ) ; QyApiConfigKit . putApiConfig ( openCpConfig ) ; QyApiConfigKit . putApiConfig ( openSuiteConfig ) ; let wxPayConfig = new WxPayApiConfig ( config . WxPayConfig . appId , config . WxPayConfig . apiKey , config . WxPayConfig . apiKey3 , config . WxPayConfig . domain , config . WxPayConfig . mchId , config . WxPayConfig . certPath , config . WxPayConfig . certP12Path , config . WxPayConfig . keyPath , config . WxPayConfig . providerAppId , config . WxPayConfig . provideMchId ) ; WxPayApiConifgKit . putConfig ( wxPayConfig ) ; WxPayApiConifgKit . setCurrentAppId ( wxPayConfig . appId ) ; WxPayApiConifgKit . devMode = true ; ApiConfigKit . putApiConfig ( devApiConfig ) ; ApiConfigKit . putApiConfig ( openMpApiConfig ) ; ApiConfigKit . putApiConfig ( miniApiConfig ) ; ApiConfigKit . setCurrentAppId ( devApiConfig . getAppId ) ; QyApiConfigKit . putApiConfig ( qyApiConfig ) ; QyApiConfigKit . putApiConfig ( qyMiniApiConfig ) ; QyApiConfigKit . setCurrentAppId ( qyApiConfig . getAppId , qyApiConfig . getCorpId ) ; ApiConfigKit . devMode = true ; QyApiConfigKit . devMode = true ; } async serverDidReady ( ) { this . app . logger . info ( 'serverDidReady...' ) ; } async beforeClose ( ) { this . app . logger . info ( 'beforeClose...' ) ; } }