feat: 初始化 kenaito-notebook 桌面记事本项目
This commit is contained in:
Executable
+113
@@ -0,0 +1,113 @@
|
||||
export namespace models {
|
||||
|
||||
export class Note {
|
||||
id: number;
|
||||
parentId: number;
|
||||
title: string;
|
||||
content: string;
|
||||
sortOrder: number;
|
||||
isFolder: boolean;
|
||||
tag: string;
|
||||
// Go type: time
|
||||
createdAt: any;
|
||||
// Go type: time
|
||||
updatedAt: any;
|
||||
// Go type: time
|
||||
deletedAt?: any;
|
||||
children?: Note[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Note(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.parentId = source["parentId"];
|
||||
this.title = source["title"];
|
||||
this.content = source["content"];
|
||||
this.sortOrder = source["sortOrder"];
|
||||
this.isFolder = source["isFolder"];
|
||||
this.tag = source["tag"];
|
||||
this.createdAt = this.convertValues(source["createdAt"], null);
|
||||
this.updatedAt = this.convertValues(source["updatedAt"], null);
|
||||
this.deletedAt = this.convertValues(source["deletedAt"], null);
|
||||
this.children = this.convertValues(source["children"], Note);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class NoteTree {
|
||||
id: number;
|
||||
parentId: number;
|
||||
title: string;
|
||||
content: string;
|
||||
sortOrder: number;
|
||||
isFolder: boolean;
|
||||
tag: string;
|
||||
// Go type: time
|
||||
createdAt: any;
|
||||
// Go type: time
|
||||
updatedAt: any;
|
||||
// Go type: time
|
||||
deletedAt?: any;
|
||||
children?: Note[];
|
||||
children: NoteTree[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new NoteTree(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.parentId = source["parentId"];
|
||||
this.title = source["title"];
|
||||
this.content = source["content"];
|
||||
this.sortOrder = source["sortOrder"];
|
||||
this.isFolder = source["isFolder"];
|
||||
this.tag = source["tag"];
|
||||
this.createdAt = this.convertValues(source["createdAt"], null);
|
||||
this.updatedAt = this.convertValues(source["updatedAt"], null);
|
||||
this.deletedAt = this.convertValues(source["deletedAt"], null);
|
||||
this.children = this.convertValues(source["children"], Note);
|
||||
this.children = this.convertValues(source["children"], NoteTree);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user