48 lines
1004 B
TypeScript
48 lines
1004 B
TypeScript
import { Jsonify } from "type-fest";
|
|
|
|
import { FolderData } from "../data/folder.data";
|
|
import { FolderView } from "../view/folder.view";
|
|
|
|
import Domain from "./domain-base";
|
|
import { EncString } from "./enc-string";
|
|
|
|
export class Folder extends Domain {
|
|
id: string;
|
|
name: EncString;
|
|
revisionDate: Date;
|
|
|
|
constructor(obj?: FolderData) {
|
|
super();
|
|
if (obj == null) {
|
|
return;
|
|
}
|
|
|
|
this.buildDomainModel(
|
|
this,
|
|
obj,
|
|
{
|
|
id: null,
|
|
name: null,
|
|
},
|
|
["id"]
|
|
);
|
|
|
|
this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
|
|
}
|
|
|
|
decrypt(): Promise<FolderView> {
|
|
return this.decryptObj(
|
|
new FolderView(this),
|
|
{
|
|
name: null,
|
|
},
|
|
null
|
|
);
|
|
}
|
|
|
|
static fromJSON(obj: Jsonify<Folder>) {
|
|
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
|
|
return Object.assign(new Folder(), obj, { name: EncString.fromJSON(obj.name), revisionDate });
|
|
}
|
|
}
|