asignar numero de vivienda
This commit is contained in:
parent
b6b21a19c7
commit
2cea9bc217
|
@ -56,6 +56,37 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
createTenant(
|
||||
dni: string,
|
||||
name: string,
|
||||
last_name: string,
|
||||
email: string,
|
||||
phone: number,
|
||||
user_type: string,
|
||||
status: string,
|
||||
date_entry: Date,
|
||||
community_id: string,
|
||||
number_house: string,
|
||||
) {
|
||||
const pattern = { cmd: 'createTenant' };
|
||||
const payload = {
|
||||
dni: dni,
|
||||
name: name,
|
||||
last_name: last_name,
|
||||
email: email,
|
||||
phone: phone,
|
||||
password: this.generatePassword(),
|
||||
user_type: user_type,
|
||||
status: status,
|
||||
date_entry: date_entry,
|
||||
community_id: community_id,
|
||||
number_house: number_house,
|
||||
};
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
updateUser(
|
||||
_id: string,
|
||||
dni: string,
|
||||
|
|
|
@ -29,6 +29,12 @@ export class UsersController {
|
|||
return this.userService.createAdminCommunity(user);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'createTenant' })
|
||||
createTenant(@Payload() user: UserDocument) {
|
||||
return this.userService.createTenant(user);
|
||||
}
|
||||
|
||||
|
||||
@MessagePattern({ cmd: 'findAllUsers' })
|
||||
findAll() {
|
||||
return this.userService.findAll();
|
||||
|
|
|
@ -24,6 +24,32 @@ export class UsersService {
|
|||
}
|
||||
|
||||
|
||||
async createTenant(user: UserDocument) {
|
||||
let password = user.password;
|
||||
let passwordEncriptada = Md5.init(user.password);
|
||||
user.password = passwordEncriptada;
|
||||
this.userModel.create(user)
|
||||
|
||||
await this.saveTenantNumHouse(user.community_id, user.number_house, user._id);
|
||||
|
||||
let community = await this.findCommunity(user.community_id);
|
||||
user.community_id = community['name'];
|
||||
|
||||
const pattern = { cmd: 'emailCreateUserTenant' };
|
||||
const payload = {
|
||||
email: user['email'], password: password, name: user['name'],
|
||||
date_entry: user['date_entry'], community_name: community['name'],
|
||||
number_house:['number_house']
|
||||
};
|
||||
|
||||
return this.clientNotificationtApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(
|
||||
map((message: string) => ({ message })),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async createAdminCommunity(user: UserDocument) {
|
||||
let password = user.password;
|
||||
let passwordEncriptada = Md5.init(user.password);
|
||||
|
|
Loading…
Reference in New Issue