Browse Source

fix: use oldDatasService instead

pull/5444/head
Wing-Kam Wong 2 years ago committed by Pranav C
parent
commit
a61359e809
  1. 45
      packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts

45
packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts

@ -16,23 +16,17 @@ import {
} from '../../../middlewares/extract-project-id/extract-project-id.middleware'; } from '../../../middlewares/extract-project-id/extract-project-id.middleware';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { Project } from 'src/models'; import { Project } from 'src/models';
import { DatasService } from '../datas.service'; import { OldDatasService } from './old-datas.service';
@Controller() @Controller()
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) @UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt'))
export class OldDatasController { export class OldDatasController {
constructor(private readonly datasService: DatasService) {} constructor(private readonly oldDatasService: OldDatasService) {}
@Get('/nc/:projectId/api/v1/:tableName') @Get('/nc/:projectId/api/v1/:tableName')
@Acl('dataList') @Acl('dataList')
async dataList(@Request() req) { async dataList(@Request() req, @Response() res) {
const { model, view } = res.json(await this.oldDatasService.getDataList(req));
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
return await this.datasService.getDataList({
model,
view,
query: req.query,
});
} }
@Get('/nc/:projectId/api/v1/:tableName/count') @Get('/nc/:projectId/api/v1/:tableName/count')
@ -42,37 +36,12 @@ export class OldDatasController {
@Response() res, @Response() res,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
) { ) {
const { model, view } = res.json(await this.oldDatasService.getDataCount(req));
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
const project = await Project.get(model.project_id);
const countResult = await this.datasService.dataCount({
query: req.query,
projectName: project.title,
tableName: tableName,
viewName: view.title,
});
res.json(countResult);
} }
@Post('/nc/:projectId/api/v1/:tableName') @Post('/nc/:projectId/api/v1/:tableName')
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(@Request() req, @Response() res) {
@Request() req, res.json(await this.oldDatasService.dataInsert(req));
@Response() res,
@Param('tableName') tableName: string,
@Body() body: any,
) {
const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
const project = await Project.get(model.project_id);
return res.json(
await this.datasService.dataInsert({
projectName: project.title,
tableName: tableName,
viewName: view.title,
body: body,
cookie: req,
}),
);
} }
} }

Loading…
Cancel
Save