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:
Eduardo Quiros 2022-08-02 05:17:30 +00:00 committed by GitHub
commit 74c5560033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

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

View File

@ -179,6 +179,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 ===============================

View File

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

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