2022-07-01 07:39:52 +00:00
|
|
|
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' })
|
2022-07-01 07:39:52 +00:00
|
|
|
create(@Payload() commonArea: CommonAreaDocument) {
|
|
|
|
return this.commonAreasService.create(commonArea);
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'findAllCommonAreas' })
|
2022-07-01 07:39:52 +00:00
|
|
|
findAll() {
|
|
|
|
return this.commonAreasService.findAll();
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'findOneCommonArea' })
|
2022-07-01 07:39:52 +00:00
|
|
|
findOne(@Payload() id: string) {
|
2022-07-01 09:10:45 +00:00
|
|
|
let _id = id['_id'];
|
|
|
|
return this.commonAreasService.findOne(_id);
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'updateCommonArea' })
|
2022-07-01 07:39:52 +00:00
|
|
|
update(@Payload() commonArea: CommonAreaDocument) {
|
|
|
|
return this.commonAreasService.update(commonArea.id, commonArea);
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'removeCommonArea' })
|
2022-07-01 07:39:52 +00:00
|
|
|
remove(@Payload() id: string) {
|
2022-08-01 07:23:45 +00:00
|
|
|
let _id = id['id'];
|
2022-07-01 09:10:45 +00:00
|
|
|
return this.commonAreasService.remove(_id);
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
2022-08-01 06:34:52 +00:00
|
|
|
|
|
|
|
@MessagePattern({ cmd: 'findByCommunity' })
|
|
|
|
findByCommunity(@Payload() id: string) {
|
|
|
|
let _community_id = id['community_id'];
|
|
|
|
return this.commonAreasService.findByCommunity(_community_id);
|
|
|
|
}
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|