|
|
@ -26,19 +26,17 @@ export class DataTableController { |
|
|
|
constructor(private readonly dataTableService: DataTableService) {} |
|
|
|
constructor(private readonly dataTableService: DataTableService) {} |
|
|
|
|
|
|
|
|
|
|
|
// todo: Handle the error case where view doesnt belong to model
|
|
|
|
// todo: Handle the error case where view doesnt belong to model
|
|
|
|
@Get('/api/v1/base/:projectId/tables/:modelId') |
|
|
|
@Get('/api/v1/tables/:modelId') |
|
|
|
@Acl('dataList') |
|
|
|
@Acl('dataList') |
|
|
|
async dataList( |
|
|
|
async dataList( |
|
|
|
@Request() req, |
|
|
|
@Request() req, |
|
|
|
@Response() res, |
|
|
|
@Response() res, |
|
|
|
@Param('projectId') projectId: string, |
|
|
|
|
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
) { |
|
|
|
) { |
|
|
|
const startTime = process.hrtime(); |
|
|
|
const startTime = process.hrtime(); |
|
|
|
const responseData = await this.dataTableService.dataList({ |
|
|
|
const responseData = await this.dataTableService.dataList({ |
|
|
|
query: req.query, |
|
|
|
query: req.query, |
|
|
|
projectId: projectId, |
|
|
|
|
|
|
|
modelId: modelId, |
|
|
|
modelId: modelId, |
|
|
|
viewId: viewId, |
|
|
|
viewId: viewId, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -47,12 +45,11 @@ export class DataTableController { |
|
|
|
res.json(responseData); |
|
|
|
res.json(responseData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Get(['/api/v1/base/:projectId/tables/:modelId/count']) |
|
|
|
@Get(['/api/v1/tables/:modelId/count']) |
|
|
|
@Acl('dataCount') |
|
|
|
@Acl('dataCount') |
|
|
|
async dataCount( |
|
|
|
async dataCount( |
|
|
|
@Request() req, |
|
|
|
@Request() req, |
|
|
|
@Response() res, |
|
|
|
@Response() res, |
|
|
|
@Param('projectId') projectId: string, |
|
|
|
|
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
) { |
|
|
|
) { |
|
|
@ -60,24 +57,21 @@ export class DataTableController { |
|
|
|
query: req.query, |
|
|
|
query: req.query, |
|
|
|
modelId, |
|
|
|
modelId, |
|
|
|
viewId, |
|
|
|
viewId, |
|
|
|
projectId, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
res.json(countResult); |
|
|
|
res.json(countResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Post(['/api/v1/base/:projectId/tables/:modelId']) |
|
|
|
@Post(['/api/v1/tables/:modelId']) |
|
|
|
@HttpCode(200) |
|
|
|
@HttpCode(200) |
|
|
|
@Acl('dataInsert') |
|
|
|
@Acl('dataInsert') |
|
|
|
async dataInsert( |
|
|
|
async dataInsert( |
|
|
|
@Request() req, |
|
|
|
@Request() req, |
|
|
|
@Param('projectId') projectId: string, |
|
|
|
|
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Body() body: any, |
|
|
|
@Body() body: any, |
|
|
|
) { |
|
|
|
) { |
|
|
|
return await this.dataTableService.dataInsert({ |
|
|
|
return await this.dataTableService.dataInsert({ |
|
|
|
projectId: projectId, |
|
|
|
|
|
|
|
modelId: modelId, |
|
|
|
modelId: modelId, |
|
|
|
body: body, |
|
|
|
body: body, |
|
|
|
viewId, |
|
|
|
viewId, |
|
|
@ -85,41 +79,35 @@ export class DataTableController { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Patch(['/api/v1/base/:projectId/tables/:modelId']) |
|
|
|
@Patch(['/api/v1/tables/:modelId']) |
|
|
|
@Acl('dataUpdate') |
|
|
|
@Acl('dataUpdate') |
|
|
|
async dataUpdate( |
|
|
|
async dataUpdate( |
|
|
|
@Request() req, |
|
|
|
@Request() req, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Param('rowId') rowId: string, |
|
|
|
@Param('rowId') rowId: string, |
|
|
|
@Param('projectId') projectId: string, |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
return await this.dataTableService.dataUpdate({ |
|
|
|
return await this.dataTableService.dataUpdate({ |
|
|
|
modelId: modelId, |
|
|
|
modelId: modelId, |
|
|
|
body: req.body, |
|
|
|
body: req.body, |
|
|
|
cookie: req, |
|
|
|
cookie: req, |
|
|
|
viewId, |
|
|
|
viewId, |
|
|
|
// rowId: rowId,
|
|
|
|
|
|
|
|
projectId, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Delete(['/api/v1/base/:projectId/tables/:modelId']) |
|
|
|
@Delete(['/api/v1/tables/:modelId']) |
|
|
|
@Acl('dataDelete') |
|
|
|
@Acl('dataDelete') |
|
|
|
async dataDelete( |
|
|
|
async dataDelete( |
|
|
|
@Request() req, |
|
|
|
@Request() req, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Param('modelId') modelId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Query('viewId') viewId: string, |
|
|
|
@Param('rowId') rowId: string, |
|
|
|
@Param('rowId') rowId: string, |
|
|
|
@Param('projectId') projectId: string, |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
return await this.dataTableService.dataDelete({ |
|
|
|
return await this.dataTableService.dataDelete({ |
|
|
|
modelId: modelId, |
|
|
|
modelId: modelId, |
|
|
|
cookie: req, |
|
|
|
cookie: req, |
|
|
|
viewId, |
|
|
|
viewId, |
|
|
|
body: req.body, |
|
|
|
body: req.body, |
|
|
|
// rowId: rowId,
|
|
|
|
|
|
|
|
projectId, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|