From cd0e76d017c318dbc8b529b2853509074137dcef Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 25 Mar 2020 18:20:43 +0100 Subject: [PATCH] Ready to implement account export --- src/controllers/AccountController.ts | 14 ++++++++++++-- src/entities/AccountExport.ts | 20 ++++++++++++++++++++ src/helpers/AccountHelper.ts | 17 +++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/entities/AccountExport.ts diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index 61f2c32..1eb31c9 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -220,8 +220,18 @@ export class AccountController { public static async ExportData(h: RequestHandler) { await h.needUserPostPassword("password"); - // TODO : implement - h.error(500, "Method not implemented yet."); + const data = await AccountHelper.Export(h.getUserId()); + + const out: any = { + userID: data.userID + }; + + + + // TODO : continue + + + h.send(out); } /** diff --git a/src/entities/AccountExport.ts b/src/entities/AccountExport.ts new file mode 100644 index 0000000..10b4082 --- /dev/null +++ b/src/entities/AccountExport.ts @@ -0,0 +1,20 @@ +/** + * Account data export + * + * @author Pierre Hubert + */ + +export interface AccountExportBuilder { + userID: number; +} + +export class AccountExport implements AccountExportBuilder { + userID: number; + + public constructor(info: AccountExportBuilder) { + for (const key in info) { + if (info.hasOwnProperty(key)) + this[key] = info[key]; + } + } +} \ No newline at end of file diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 6eb3726..e87b1ad 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -6,6 +6,7 @@ import { UserHelper } from "./UserHelper"; import { time, mysql_date } from "../utils/DateUtils"; import { NewAccount } from "../entities/NewAccount"; import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from "../entities/User"; +import { AccountExport } from "../entities/AccountExport"; /** * Account helper @@ -374,4 +375,20 @@ export class AccountHelper { } }); } + + /** + * Export all the data of an account + * + * @param userID Target user ID + */ + public static async Export(userID: number) : Promise { + const data = new AccountExport({ + userID: userID + }) + + + // TODO : continue + + return data; + } } \ No newline at end of file