50 lines
1.7 KiB
Handlebars
50 lines
1.7 KiB
Handlebars
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Param,
|
|
Post,
|
|
Put,
|
|
} from '@nestjs/common';
|
|
import { {{pascalCase name}}DataOrchestrator } from '../domain/usecases/{{dashCase name}}-data.orchestrator';
|
|
import { {{pascalCase name}}Dto } from './dto/{{dashCase name}}.dto';
|
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { {{pascalCase name}}Entity } from '../domain/entities/{{dashCase name}}.entity';
|
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
|
import { Public } from 'src/core/guards';
|
|
|
|
@ApiTags(`${MODULE_NAME.{{constantCase name}}.split('-').join(' ')} - data`)
|
|
@Controller(`v1/${MODULE_NAME.{{constantCase name}} }`)
|
|
@Public(false)
|
|
@ApiBearerAuth('JWT')
|
|
export class {{pascalCase name}}DataController {
|
|
constructor(private orchestrator: {{pascalCase name}}DataOrchestrator) {}
|
|
|
|
@Post()
|
|
async create(
|
|
@Body() data: {{pascalCase name}}Dto,
|
|
): Promise<{{pascalCase name}}Entity> {
|
|
return await this.orchestrator.create(data);
|
|
}
|
|
|
|
@Put('/batch-delete')
|
|
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchDelete(body.ids);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(
|
|
@Param('id') dataId: string,
|
|
@Body() data: Create{{pascalCase name}}Dto,
|
|
): Promise<{{pascalCase name}}Entity> {
|
|
return await this.orchestrator.update(dataId, data);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async delete(@Param('id') dataId: string): Promise<string> {
|
|
return await this.orchestrator.delete(dataId);
|
|
}
|
|
}
|
|
|