81 lines
2.5 KiB
Handlebars
81 lines
2.5 KiB
Handlebars
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Param,
|
|
Patch,
|
|
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(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);
|
|
}
|
|
|
|
@Patch(':id/active')
|
|
async active(@Param('id') dataId: string): Promise<String> {
|
|
return await this.orchestrator.active(dataId);
|
|
}
|
|
|
|
@Put('/batch-active')
|
|
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchActive(body.ids);
|
|
}
|
|
|
|
@Patch(':id/confirm')
|
|
async confirm(@Param('id') dataId: string): Promise<String> {
|
|
return await this.orchestrator.confirm(dataId);
|
|
}
|
|
|
|
@Put('/batch-confirm')
|
|
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchConfirm(body.ids);
|
|
}
|
|
|
|
@Patch(':id/inactive')
|
|
async inactive(@Param('id') dataId: string): Promise<String> {
|
|
return await this.orchestrator.inactive(dataId);
|
|
}
|
|
|
|
@Put('/batch-inactive')
|
|
async batchInactive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchInactive(body.ids);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(
|
|
@Param('id') dataId: string,
|
|
@Body() data: {{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);
|
|
}
|
|
}
|