forked from typijs/typijs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfolder.controller.ts
More file actions
37 lines (30 loc) · 1.51 KB
/
folder.controller.ts
File metadata and controls
37 lines (30 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import * as express from 'express';
import * as mongoose from 'mongoose';
import * as httpStatus from 'http-status';
import { IContentDocument } from '../content/content.model';
import { FolderService } from './folder.service';
export abstract class FolderController<T extends IContentDocument> {
private folderService: FolderService<T>;
constructor(contentModel: mongoose.Model<T>) {
this.folderService = new FolderService(contentModel);
}
//Create new folder
createFolderContent = async (req: express.Request, res: express.Response) => {
const contentFolder = this.folderService.createModelInstance(req.body);
const item = await this.folderService.createContentFolder(contentFolder)
res.status(httpStatus.OK).json(item)
}
updateFolderName = async (req: express.Request, res: express.Response) => {
const contentFolder = this.folderService.createModelInstance(req.body);
const item = await this.folderService.updateFolderName(req.params.id, contentFolder.name)
res.status(httpStatus.OK).json(item)
}
getFoldersByParentId = async (req: express.Request, res: express.Response) => {
const items = await this.folderService.getFolderChildren(req.params.parentId)
res.status(httpStatus.OK).json(items)
}
getContentsByFolder = async (req: express.Request, res: express.Response) => {
const items = await this.folderService.getContentsByFolder(req.params.parentId)
res.status(httpStatus.OK).json(items)
}
}