katoikia-app/servicio-areas-comunes/src/common_areas/common_areas.controller.ts

43 lines
1.3 KiB
TypeScript
Raw Normal View History

import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { CommonAreaDocument } from 'src/schemas/common_area.schema';
import { CommonAreasService } from './common_areas.service';
@Controller()
export class CommonAreasController {
constructor(private readonly commonAreasService: CommonAreasService) {}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'createCommonArea' })
create(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.create(commonArea);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'findAllCommonAreas' })
findAll() {
return this.commonAreasService.findAll();
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'findOneCommonArea' })
findOne(@Payload() id: string) {
let _id = id['_id'];
return this.commonAreasService.findOne(_id);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'updateCommonArea' })
update(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.update(commonArea.id, commonArea);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'removeCommonArea' })
remove(@Payload() id: string) {
2022-08-01 07:23:45 +00:00
let _id = id['id'];
return this.commonAreasService.remove(_id);
}
@MessagePattern({ cmd: 'findByCommunity' })
findByCommunity(@Payload() id: string) {
let _community_id = id['community_id'];
return this.commonAreasService.findByCommunity(_community_id);
}
}