Merge pull request #146 from DeimosPr4/UH-activar&desactivarComunidad
Backend del servicio para activar y desactivar una comunidad de vivienda
This commit is contained in:
commit
74c5560033
|
@ -168,7 +168,13 @@ export class AppController {
|
|||
findCommunityAdmin(@Body('community_id') community_id: string) {
|
||||
return this.appService.findCommunityAdmin(community_id);
|
||||
}
|
||||
|
||||
@Post('community/changeStatus')
|
||||
changeStatus(
|
||||
@Body('id') pId: string,
|
||||
@Body('status') pStatus: string,
|
||||
) {
|
||||
return this.appService.changeStatus(pId, pStatus);
|
||||
}
|
||||
// #==== API Common Areas
|
||||
@Post('commonArea/createCommonArea')
|
||||
createCommonArea(
|
||||
|
|
|
@ -179,6 +179,13 @@ export class AppService {
|
|||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
changeStatus(pId: string, pStatus: string) {
|
||||
const pattern = { cmd: 'changeStatus' };
|
||||
const payload = { id: pId, status: pStatus };
|
||||
return this.clientCommunityApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
// ====================== COMMUNITIES ===============================
|
||||
|
||||
|
|
|
@ -45,4 +45,14 @@ export class CommunitiesController {
|
|||
let _id = id['_id'];
|
||||
return this.communitiesService.remove(_id);
|
||||
}
|
||||
|
||||
//cambiar de estado
|
||||
@MessagePattern({ cmd: 'changeStatus' })
|
||||
changeStatus(@Payload() body: string) {
|
||||
let pid = body['id'];
|
||||
let pstatus = body['status'];
|
||||
console.log(pid);
|
||||
console.log(pstatus);
|
||||
return this.communitiesService.changeStatus(pid,pstatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,12 @@ export class CommunitiesService {
|
|||
});
|
||||
}
|
||||
|
||||
async changeStatus(id: string, status: string) {
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, {status: status}, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
async findCommunityAdmin(community: string, user_type: string) {
|
||||
const pattern = { cmd: 'findOneCommunityUser' };
|
||||
const payload = { community_id: community, user_type: user_type };
|
||||
|
|
Loading…
Reference in New Issue