Neo platform - First Version
This commit is contained in:
98
backend/src/object/runtime-object.controller.ts
Normal file
98
backend/src/object/runtime-object.controller.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Param,
|
||||
Body,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ObjectService } from './object.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { CurrentUser } from '../auth/current-user.decorator';
|
||||
import { TenantId } from '../tenant/tenant.decorator';
|
||||
|
||||
@Controller('runtime/objects')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class RuntimeObjectController {
|
||||
constructor(private objectService: ObjectService) {}
|
||||
|
||||
@Get(':objectApiName/records')
|
||||
async getRecords(
|
||||
@TenantId() tenantId: string,
|
||||
@Param('objectApiName') objectApiName: string,
|
||||
@CurrentUser() user: any,
|
||||
@Query() query: any,
|
||||
) {
|
||||
return this.objectService.getRecords(
|
||||
tenantId,
|
||||
objectApiName,
|
||||
user.userId,
|
||||
query,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':objectApiName/records/:id')
|
||||
async getRecord(
|
||||
@TenantId() tenantId: string,
|
||||
@Param('objectApiName') objectApiName: string,
|
||||
@Param('id') id: string,
|
||||
@CurrentUser() user: any,
|
||||
) {
|
||||
return this.objectService.getRecord(
|
||||
tenantId,
|
||||
objectApiName,
|
||||
id,
|
||||
user.userId,
|
||||
);
|
||||
}
|
||||
|
||||
@Post(':objectApiName/records')
|
||||
async createRecord(
|
||||
@TenantId() tenantId: string,
|
||||
@Param('objectApiName') objectApiName: string,
|
||||
@Body() data: any,
|
||||
@CurrentUser() user: any,
|
||||
) {
|
||||
return this.objectService.createRecord(
|
||||
tenantId,
|
||||
objectApiName,
|
||||
data,
|
||||
user.userId,
|
||||
);
|
||||
}
|
||||
|
||||
@Put(':objectApiName/records/:id')
|
||||
async updateRecord(
|
||||
@TenantId() tenantId: string,
|
||||
@Param('objectApiName') objectApiName: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: any,
|
||||
@CurrentUser() user: any,
|
||||
) {
|
||||
return this.objectService.updateRecord(
|
||||
tenantId,
|
||||
objectApiName,
|
||||
id,
|
||||
data,
|
||||
user.userId,
|
||||
);
|
||||
}
|
||||
|
||||
@Delete(':objectApiName/records/:id')
|
||||
async deleteRecord(
|
||||
@TenantId() tenantId: string,
|
||||
@Param('objectApiName') objectApiName: string,
|
||||
@Param('id') id: string,
|
||||
@CurrentUser() user: any,
|
||||
) {
|
||||
return this.objectService.deleteRecord(
|
||||
tenantId,
|
||||
objectApiName,
|
||||
id,
|
||||
user.userId,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user