obtener inquilinos api

This commit is contained in:
Mariela 2022-07-23 23:54:05 -06:00
parent e34fb7d5cc
commit 72ea9d2033
4 changed files with 40 additions and 0 deletions

View File

@ -77,6 +77,7 @@ export class AppController {
allUsersAdminComunidad() {
return this.appService.allUsersAdminComunidad();
}
@Get('user/findGuards/:community')
findGuardsCommunity(
@Param('community_id') community_id: string
@ -84,6 +85,11 @@ export class AppController {
return this.appService.findGuardsCommunity(community_id);
}
@Get('user/findTenants')
allUsersTenants() {
return this.appService.allUsersTenants();
}
@Get('user/find/:dni')
findUser(
@Param('dni') paramUserDNI: string

View File

@ -95,6 +95,17 @@ export class AppService {
);
}
allUsersTenants() {
const pattern = { cmd: 'findTenants' };
const payload = {};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findUser(paramUserDNI: string) {
const pattern = { cmd: 'findUserDNI' };

View File

@ -41,6 +41,18 @@ export class UsersController {
}
@MessagePattern({ cmd: 'findTenantsCommunity' })
findTenantsCommunity(@Payload() community_id: string) {
let pcommunity_id = community_id['community_id'];
return this.userService.findTenantsCommunity(pcommunity_id);
}
@MessagePattern({ cmd: 'findTenants' })
findTenants() {
return this.userService.findTenants();
}
@MessagePattern({ cmd: 'updateUser' })
update(@Payload() user: UserDocument) {
return this.userService.update(user.id, user);

View File

@ -87,6 +87,17 @@ export class UsersService {
return this.userModel.find({ user_type: 2 }).exec();
}
//find inquilinos
async findTenants(): Promise<User[]> {
return this.userModel.find({ user_type: 3 }).exec();
}
//find inquilinos
async findTenantsCommunity(pcommunity_id: string): Promise<User[]> {
return this.userModel.find({ community_id: pcommunity_id, user_type: 4 }).exec();
}
async testSendMail(user: UserDocument) {
let passwordEncriptada = Md5.init(user.password);