function para obtener los numeros de casas de los inquilinos
This commit is contained in:
		
							parent
							
								
									8ff8382d54
								
							
						
					
					
						commit
						9cac88f333
					
				| 
						 | 
					@ -7,7 +7,7 @@ import { Tenant, TenantSchema } from './tenant.schema';
 | 
				
			||||||
@Schema()
 | 
					@Schema()
 | 
				
			||||||
export class House extends Document {
 | 
					export class House extends Document {
 | 
				
			||||||
  @Prop({ default: ' ' })
 | 
					  @Prop({ default: ' ' })
 | 
				
			||||||
  number_house: string;
 | 
					  number: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Prop({ default: 'desocupada' })
 | 
					  @Prop({ default: 'desocupada' })
 | 
				
			||||||
  state: string;
 | 
					  state: string;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,24 +25,26 @@ export class UsersService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async createAdminCommunity(user: UserDocument) {
 | 
					  async createAdminCommunity(user: UserDocument) {
 | 
				
			||||||
      let password = user.password;
 | 
					    let password = user.password;
 | 
				
			||||||
      let passwordEncriptada = Md5.init(user.password);
 | 
					    let passwordEncriptada = Md5.init(user.password);
 | 
				
			||||||
      user.password = passwordEncriptada;
 | 
					    user.password = passwordEncriptada;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       this.userModel.create(user)
 | 
					    this.userModel.create(user)
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let community = await this.findCommunity(user.community_id);
 | 
					
 | 
				
			||||||
      user.community_id = community['name'];
 | 
					    let community = await this.findCommunity(user.community_id);
 | 
				
			||||||
  
 | 
					    user.community_id = community['name'];
 | 
				
			||||||
      const pattern = { cmd: 'emailCreateUserAdminCommunity' };
 | 
					
 | 
				
			||||||
      const payload = { email: user['email'], password: password, name: user['name'], 
 | 
					    const pattern = { cmd: 'emailCreateUserAdminCommunity' };
 | 
				
			||||||
      date_entry: user['date_entry'], community_name: community['name'] };
 | 
					    const payload = {
 | 
				
			||||||
      return this.clientNotificationtApp
 | 
					      email: user['email'], password: password, name: user['name'],
 | 
				
			||||||
        .send<string>(pattern, payload)
 | 
					      date_entry: user['date_entry'], community_name: community['name']
 | 
				
			||||||
        .pipe(
 | 
					    };
 | 
				
			||||||
          map((message: string) => ({ message })),
 | 
					    return this.clientNotificationtApp
 | 
				
			||||||
        );
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((message: string) => ({ message })),
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async findCommunity(community_id: string) {
 | 
					  async findCommunity(community_id: string) {
 | 
				
			||||||
| 
						 | 
					@ -117,16 +119,19 @@ export class UsersService {
 | 
				
			||||||
    return this.userModel.find({ user_type: 2 }).exec();
 | 
					    return this.userModel.find({ user_type: 2 }).exec();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  //find inquilinos
 | 
					  //find inquilinos
 | 
				
			||||||
  async findTenants(): Promise<User[]> {
 | 
					  async findTenants(): Promise<User[]> {
 | 
				
			||||||
    return this.userModel.find({ user_type: 3 }).exec();
 | 
					    return this.userModel.find({ user_type: 3 }).exec();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  //find inquilinos
 | 
					  //find inquilinos
 | 
				
			||||||
  async findTenantsCommunity(pcommunity_id: string): Promise<User[]> {
 | 
					  async findTenantsCommunity(pcommunity_id: string): Promise<User[]> {
 | 
				
			||||||
    return this.userModel.find({ community_id: pcommunity_id, user_type: 4 }).exec();
 | 
					    let houses = await this.findCommunityHouses(pcommunity_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return this.userModel.find({ community_id: pcommunity_id, user_type: 4 }).exec()
 | 
				
			||||||
 | 
					    .then();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async testSendMail(user: UserDocument) {
 | 
					  async testSendMail(user: UserDocument) {
 | 
				
			||||||
| 
						 | 
					@ -174,5 +179,19 @@ export class UsersService {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async findCommunityHouses(community_id: string) {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'findOneCommunity' }
 | 
				
			||||||
 | 
					    const payload = { _id: community_id }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let callback = await this.clientCommunityApp
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((response: string) => ({ response }))
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    const finalValue = await lastValueFrom(callback);
 | 
				
			||||||
 | 
					    const response = finalValue['response'];
 | 
				
			||||||
 | 
					    console.log(response['houses']);
 | 
				
			||||||
 | 
					    return response['houses'];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue