Merge branch 'dev' into US-17-VerPerfildeinformacióndecomunidaddevivienda

This commit is contained in:
Mariela 2022-08-01 23:17:39 -06:00
commit d6b95dd143
4 changed files with 30 additions and 1 deletions

View File

@ -173,7 +173,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(

View File

@ -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 })));
}
//GET parameter from API

View File

@ -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);
}
}

View File

@ -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 };