mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 08:27:13 +08:00
add the logic in userInfoResponse hook to update user info in db
This commit is contained in:
@@ -27,24 +27,33 @@ async function initDb() {
|
|||||||
JobInfo,
|
JobInfo,
|
||||||
JobInfoChangeLog,
|
JobInfoChangeLog,
|
||||||
BossActiveStatusRecord,
|
BossActiveStatusRecord,
|
||||||
UserInfo
|
UserInfo,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
return appDataSource.initialize();
|
return appDataSource.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SqlitePlugin {
|
export default class SqlitePlugin {
|
||||||
initPromise: Promise<DataSource>
|
initPromise: Promise<DataSource>;
|
||||||
|
|
||||||
constructor () {
|
constructor() {
|
||||||
this.initPromise = initDb()
|
this.initPromise = initDb();
|
||||||
}
|
}
|
||||||
apply (hooks) {
|
apply(hooks) {
|
||||||
hooks.userInfoResponse.tapPromise(
|
hooks.userInfoResponse.tapPromise("SqlitePlugin", async (userInfoResponse) => {
|
||||||
'SqlitePlugin',
|
if (userInfoResponse.code !== 0) {
|
||||||
(userInfo) => new Promise((resolve, reject) => {
|
return
|
||||||
console.log(userInfo)
|
}
|
||||||
})
|
const { zpData: userInfo } = userInfoResponse
|
||||||
)
|
console.log(userInfo);
|
||||||
|
const ds = await this.initPromise;
|
||||||
|
const userInfoRepository = ds.getRepository(UserInfo);
|
||||||
|
|
||||||
|
const user = new UserInfo();
|
||||||
|
user.encryptUserId = userInfo.encryptUserId
|
||||||
|
user.name = userInfo.name
|
||||||
|
|
||||||
|
return await userInfoRepository.save(user)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user