Backend del servicio para activar y desactivar una comunidad de vivienda
This commit is contained in:
parent
721c9f6fa7
commit
b9f04f7221
|
@ -162,7 +162,13 @@ export class AppController {
|
||||||
findCommunityAdmin(@Body('community_id') community_id: string) {
|
findCommunityAdmin(@Body('community_id') community_id: string) {
|
||||||
return this.appService.findCommunityAdmin(community_id);
|
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
|
// #==== API Common Areas
|
||||||
@Post('commonArea/createCommonArea')
|
@Post('commonArea/createCommonArea')
|
||||||
createCommonArea(
|
createCommonArea(
|
||||||
|
|
|
@ -161,6 +161,13 @@ export class AppService {
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
.pipe(map((message: string) => ({ message })));
|
.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 ===============================
|
// ====================== COMMUNITIES ===============================
|
||||||
|
|
||||||
|
|
|
@ -45,4 +45,14 @@ export class CommunitiesController {
|
||||||
let _id = id['_id'];
|
let _id = id['_id'];
|
||||||
return this.communitiesService.remove(_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) {
|
async findCommunityAdmin(community: string, user_type: string) {
|
||||||
const pattern = { cmd: 'findOneCommunityUser' };
|
const pattern = { cmd: 'findOneCommunityUser' };
|
||||||
const payload = { community_id: community, user_type: user_type };
|
const payload = { community_id: community, user_type: user_type };
|
||||||
|
|
Loading…
Reference in New Issue