Add more features to NotesService

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-07-26 20:59:12 +02:00
parent 0d4c489aa5
commit 4cd574306e
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -1,5 +1,10 @@
import { Injectable, Logger } from "@nestjs/common";
import { Injectable, Logger } from '@nestjs/common';
import { NoteMetadataDto } from './note-metadata.dto';
import {
NotePermissionsDto,
NotePermissionsUpdateDto,
} from './note-permissions.dto';
import { NoteDto } from './note.dto';
@Injectable()
export class NotesService {
@ -36,4 +41,158 @@ export class NotesService {
},
];
}
createNote(noteContent: string, alias?: NoteMetadataDto['alias']): NoteDto {
this.logger.warn('Using hardcoded data!');
return {
content: noteContent,
metdata: {
alias: alias,
createTime: new Date(),
description: 'Very descriptive text.',
editedBy: [],
id: 'foobar-barfoo',
permission: {
owner: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
sharedTo: [],
},
tags: [],
title: 'Title!',
updateTime: new Date(),
updateUser: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
viewCount: 42,
},
editedByAtPosition: [],
};
}
getNoteByIdOrAlias(noteIdOrAlias: string) {
this.logger.warn('Using hardcoded data!');
return {
content: 'noteContent',
metdata: {
alias: null,
createTime: new Date(),
description: 'Very descriptive text.',
editedBy: [],
id: noteIdOrAlias,
permission: {
owner: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
sharedTo: [],
},
tags: [],
title: 'Title!',
updateTime: new Date(),
updateUser: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
viewCount: 42,
},
editedByAtPosition: [],
};
}
deleteNoteByIdOrAlias(noteIdOrAlias: string) {
return;
}
updateNoteByIdOrAlias(noteIdOrAlias: string, noteContent: string) {
this.logger.warn('Using hardcoded data!');
return {
content: noteContent,
metdata: {
alias: null,
createTime: new Date(),
description: 'Very descriptive text.',
editedBy: [],
id: noteIdOrAlias,
permission: {
owner: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
sharedTo: [],
},
tags: [],
title: 'Title!',
updateTime: new Date(),
updateUser: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
viewCount: 42,
},
editedByAtPosition: [],
};
}
getNoteMetadata(noteIdOrAlias: string): NoteMetadataDto {
return {
alias: null,
createTime: new Date(),
description: 'Very descriptive text.',
editedBy: [],
id: noteIdOrAlias,
permission: {
owner: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
sharedTo: [],
},
tags: [],
title: 'Title!',
updateTime: new Date(),
updateUser: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
viewCount: 42,
};
}
updateNotePermissions(
noteIdOrAlias: string,
newPermissions: NotePermissionsUpdateDto,
): NotePermissionsDto {
return {
owner: {
displayName: 'foo',
userName: 'fooUser',
email: 'foo@example.com',
photo: '',
},
sharedTo: [],
};
}
getNoteContent(noteIdOrAlias: string) {
return '# Markdown';
}
}