2022-06-29 09:23:07 +00:00
|
|
|
import { Injectable, Inject } from '@nestjs/common';
|
2022-07-25 04:38:48 +00:00
|
|
|
import { ClientProxy } from '@nestjs/microservices';
|
|
|
|
import { map } from 'rxjs/operators';
|
2022-08-16 22:36:06 +00:00
|
|
|
import { lastValueFrom } from 'rxjs';
|
2022-06-29 02:30:10 +00:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class AppService {
|
|
|
|
constructor(
|
2022-06-29 09:23:07 +00:00
|
|
|
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
|
2022-07-25 04:38:48 +00:00
|
|
|
@Inject('SERVICIO_COMUNIDADES')
|
|
|
|
private readonly clientCommunityApp: ClientProxy,
|
|
|
|
@Inject('SERVICIO_AREAS_COMUNES')
|
|
|
|
private readonly clientCommonAreaApp: ClientProxy,
|
2022-07-01 09:09:48 +00:00
|
|
|
@Inject('SERVICIO_INVITADOS') private readonly clientGuestApp: ClientProxy,
|
2022-07-01 09:48:27 +00:00
|
|
|
@Inject('SERVICIO_PAGOS') private readonly clientPaymentApp: ClientProxy,
|
2022-07-25 04:38:48 +00:00
|
|
|
@Inject('SERVICIO_RESERVACIONES')
|
|
|
|
private readonly clientReservationApp: ClientProxy,
|
2022-07-01 20:53:38 +00:00
|
|
|
@Inject('SERVICIO_POSTS') private readonly clientPostApp: ClientProxy,
|
2022-07-01 23:11:32 +00:00
|
|
|
@Inject('SERVICIO_REPORTES') private readonly clientReportApp: ClientProxy,
|
2022-07-25 04:38:48 +00:00
|
|
|
@Inject('SERVICIO_NOTIFICACIONES')
|
|
|
|
private readonly clientNotificationtApp: ClientProxy,
|
2022-08-03 03:52:30 +00:00
|
|
|
) { }
|
2022-07-01 01:42:50 +00:00
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== USERS ===============================
|
2022-07-01 01:42:50 +00:00
|
|
|
|
2022-06-29 09:23:07 +00:00
|
|
|
//POST parameter from API
|
2022-07-25 04:38:48 +00:00
|
|
|
createUser(
|
|
|
|
dni: string,
|
|
|
|
name: string,
|
|
|
|
last_name: string,
|
|
|
|
email: string,
|
|
|
|
phone: number,
|
|
|
|
password: string,
|
|
|
|
user_type: string,
|
|
|
|
status: string,
|
|
|
|
date_entry: Date,
|
|
|
|
community_id: string,
|
2022-08-22 06:07:33 +00:00
|
|
|
number_house: string,
|
2022-07-25 04:38:48 +00:00
|
|
|
) {
|
2022-06-29 09:23:07 +00:00
|
|
|
const pattern = { cmd: 'createUser' };
|
2022-07-01 01:42:50 +00:00
|
|
|
const payload = {
|
2022-07-25 04:38:48 +00:00
|
|
|
dni: dni,
|
|
|
|
name: name,
|
|
|
|
last_name: last_name,
|
|
|
|
email: email,
|
|
|
|
phone: phone,
|
|
|
|
password: password,
|
|
|
|
user_type: user_type,
|
|
|
|
status: status,
|
|
|
|
date_entry: date_entry,
|
|
|
|
community_id: community_id,
|
2022-08-22 06:07:33 +00:00
|
|
|
number_house: number_house,
|
2022-07-01 01:42:50 +00:00
|
|
|
};
|
2022-06-29 09:23:07 +00:00
|
|
|
return this.clientUserApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 09:23:07 +00:00
|
|
|
}
|
2022-06-29 02:30:10 +00:00
|
|
|
|
2022-08-22 18:35:40 +00:00
|
|
|
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 })));
|
|
|
|
}
|
|
|
|
|
2022-08-04 04:54:37 +00:00
|
|
|
updateUser(
|
2022-08-22 06:07:33 +00:00
|
|
|
_id: string,
|
2022-08-21 10:35:59 +00:00
|
|
|
dni: string,
|
|
|
|
name: string,
|
2022-08-04 04:54:37 +00:00
|
|
|
last_name: string,
|
|
|
|
email: string,
|
|
|
|
phone: number,
|
|
|
|
password: string,
|
|
|
|
user_type: string,
|
|
|
|
status: string,
|
|
|
|
date_entry: Date,
|
|
|
|
community_id: string,
|
2022-08-22 06:07:33 +00:00
|
|
|
number_house: string,
|
2022-08-04 04:54:37 +00:00
|
|
|
) {
|
|
|
|
const pattern = { cmd: 'updateUser' };
|
|
|
|
const payload = {
|
2022-08-22 06:07:33 +00:00
|
|
|
id: _id,
|
2022-08-04 04:54:37 +00:00
|
|
|
dni: dni,
|
|
|
|
name: name,
|
|
|
|
last_name: last_name,
|
|
|
|
email: email,
|
|
|
|
phone: phone,
|
|
|
|
password: password,
|
|
|
|
user_type: user_type,
|
|
|
|
status: status,
|
|
|
|
date_entry: date_entry,
|
|
|
|
community_id: community_id,
|
2022-08-22 06:07:33 +00:00
|
|
|
number_house: number_house,
|
2022-08-04 04:54:37 +00:00
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-08-22 11:15:29 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGuard(
|
|
|
|
_id: string,
|
|
|
|
dni: string,
|
|
|
|
name: string,
|
|
|
|
last_name: string,
|
|
|
|
email: string,
|
|
|
|
phone: number,
|
|
|
|
password: string,
|
|
|
|
user_type: string,
|
|
|
|
status: string,
|
|
|
|
date_entry: Date,
|
|
|
|
community_id: string,
|
|
|
|
) {
|
|
|
|
const pattern = { cmd: 'updateGuard' };
|
|
|
|
const payload = {
|
|
|
|
id: _id,
|
|
|
|
dni: dni,
|
|
|
|
name: name,
|
|
|
|
last_name: last_name,
|
|
|
|
email: email,
|
|
|
|
phone: phone,
|
|
|
|
password: password,
|
|
|
|
user_type: user_type,
|
|
|
|
status: status,
|
|
|
|
date_entry: date_entry,
|
|
|
|
community_id: community_id,
|
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-08-04 04:54:37 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-07-01 01:42:50 +00:00
|
|
|
//POST parameter from API
|
|
|
|
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
|
2022-07-26 22:59:29 +00:00
|
|
|
, user_type: string, status: string, date_entry: Date) {
|
2022-07-01 01:42:50 +00:00
|
|
|
const pattern = { cmd: 'createAdminSystem' };
|
|
|
|
const payload = {
|
|
|
|
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
2022-07-26 22:59:29 +00:00
|
|
|
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry
|
2022-07-01 01:42:50 +00:00
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 01:42:50 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 02:55:01 +00:00
|
|
|
createGuard(dni: string, name: string, last_name: string, email: string, phone: number
|
2022-07-26 22:59:29 +00:00
|
|
|
, user_type: string, status: string, date_entry: Date, community_id: string) {
|
2022-07-19 02:55:01 +00:00
|
|
|
const pattern = { cmd: 'createGuard' };
|
|
|
|
const payload = {
|
|
|
|
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
2022-07-26 22:59:29 +00:00
|
|
|
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id
|
|
|
|
|
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-26 22:59:29 +00:00
|
|
|
}
|
|
|
|
|
2022-08-03 03:52:30 +00:00
|
|
|
|
2022-07-26 22:59:29 +00:00
|
|
|
createAdminCommunity(dni: string, name: string, last_name: string, email: string, phone: number
|
|
|
|
, user_type: string, status: string, date_entry: Date, community_id: string) {
|
|
|
|
const pattern = { cmd: 'createAdminCommunity' };
|
|
|
|
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
|
2022-07-22 05:10:36 +00:00
|
|
|
|
2022-07-19 02:55:01 +00:00
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(
|
|
|
|
map((message: string) => ({ message })),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-01 01:42:50 +00:00
|
|
|
allUsers() {
|
2022-06-29 09:23:07 +00:00
|
|
|
const pattern = { cmd: 'findAllUsers' };
|
2022-06-29 02:30:10 +00:00
|
|
|
const payload = {};
|
2022-06-29 09:23:07 +00:00
|
|
|
return this.clientUserApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 02:30:10 +00:00
|
|
|
}
|
2022-06-29 10:12:27 +00:00
|
|
|
|
2022-07-15 01:01:02 +00:00
|
|
|
allUsersAdminSistema() {
|
|
|
|
const pattern = { cmd: 'findAdminSistema' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-15 01:01:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 03:16:02 +00:00
|
|
|
allUsersAdminComunidad() {
|
|
|
|
const pattern = { cmd: 'findAdminComunidad' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-15 03:16:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-24 05:54:05 +00:00
|
|
|
allUsersTenants() {
|
|
|
|
const pattern = { cmd: 'findTenants' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(
|
|
|
|
map((message: string) => ({ message })),
|
|
|
|
);
|
|
|
|
}
|
2022-08-03 03:52:30 +00:00
|
|
|
|
2022-07-24 05:54:05 +00:00
|
|
|
|
2022-07-01 01:42:50 +00:00
|
|
|
//GET parameter from API
|
|
|
|
findUser(paramUserDNI: string) {
|
|
|
|
const pattern = { cmd: 'findUserDNI' };
|
|
|
|
const payload = { dni: paramUserDNI };
|
2022-06-29 10:12:27 +00:00
|
|
|
return this.clientUserApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 10:12:27 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 04:28:56 +00:00
|
|
|
findGuardsCommunity(community_id: string) {
|
|
|
|
const pattern = { cmd: 'findGuardsCommunity' };
|
|
|
|
const payload = { community_id: community_id };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-19 04:28:56 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 00:19:20 +00:00
|
|
|
findTenantsCommunity(community_id: string) {
|
|
|
|
const pattern = { cmd: 'findTenantsCommunity' };
|
|
|
|
const payload = { community_id: community_id };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
2022-07-26 22:59:29 +00:00
|
|
|
|
2022-07-22 07:22:13 +00:00
|
|
|
deleteAdminSystem(id: string) {
|
|
|
|
const pattern = { cmd: 'deleteAdminSystem' };
|
|
|
|
const payload = { id: id };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-22 07:22:13 +00:00
|
|
|
}
|
|
|
|
|
2022-08-19 20:15:05 +00:00
|
|
|
deleteAdminCommunity(id: string) {
|
|
|
|
const pattern = { cmd: 'deleteAdminCommunity' };
|
|
|
|
const payload = { id: id };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-08-22 22:39:20 +00:00
|
|
|
deleteTenant(id: string, community_id: string, number_house: string) {
|
2022-08-21 10:35:59 +00:00
|
|
|
const pattern = { cmd: 'deleteTenant' };
|
2022-08-22 22:39:20 +00:00
|
|
|
const payload = { _id: id, community_id: community_id, number_house: number_house };
|
2022-08-21 10:35:59 +00:00
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-07-11 02:22:34 +00:00
|
|
|
inicioSesion(pEmail: string, pPassword: string) {
|
|
|
|
const pattern = { cmd: 'loginUser' };
|
2022-07-26 22:59:29 +00:00
|
|
|
const payload = { email: pEmail, password: pPassword };
|
2022-07-11 02:22:34 +00:00
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-11 02:22:34 +00:00
|
|
|
}
|
|
|
|
|
2022-08-22 07:22:32 +00:00
|
|
|
updateAdminSystem(_id: string, dni: string, name: string,
|
|
|
|
last_name: string, email: string, phone: number
|
|
|
|
) {
|
|
|
|
const pattern = { cmd: 'updateAdminSystem' };
|
|
|
|
const payload = {
|
|
|
|
_id: _id, dni: dni, name: name, last_name: last_name,
|
|
|
|
email: email, phone: phone
|
|
|
|
};
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:56:48 +00:00
|
|
|
//GET parameter from API
|
|
|
|
findCommunityAdmin(community_id: string) {
|
|
|
|
const pattern = { cmd: 'findCommunityAdmin' };
|
|
|
|
const payload = { community_id: community_id };
|
|
|
|
return this.clientCommunityApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-19 19:56:48 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 05:29:48 +00:00
|
|
|
|
2022-08-03 03:52:30 +00:00
|
|
|
//GET parameter from API
|
|
|
|
findUserById(id: string) {
|
2022-08-01 05:29:48 +00:00
|
|
|
const pattern = { cmd: 'findById' };
|
|
|
|
const payload = { id: id };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-08-03 03:52:30 +00:00
|
|
|
changeStatusUser(pId: string, pStatus: string) {
|
|
|
|
const pattern = { cmd: 'changeStatus' };
|
|
|
|
const payload = { id: pId, status: pStatus };
|
|
|
|
return this.clientUserApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-08-01 05:29:48 +00:00
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== COMMUNITIES ===============================
|
2022-08-03 03:52:30 +00:00
|
|
|
changeStatusCommunity(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 })));
|
|
|
|
}
|
2022-06-29 10:12:27 +00:00
|
|
|
|
|
|
|
//POST parameter from API
|
|
|
|
createCommunity(name: string, province: string, canton: string, district: string
|
2022-07-26 22:59:29 +00:00
|
|
|
, num_houses: number, phone: string, status: string, date_entry: Date, houses: []) {
|
2022-06-29 10:12:27 +00:00
|
|
|
const pattern = { cmd: 'createCommunity' };
|
2022-07-01 01:42:50 +00:00
|
|
|
const payload = {
|
2022-07-25 04:38:48 +00:00
|
|
|
name: name,
|
|
|
|
province: province,
|
|
|
|
canton: canton,
|
|
|
|
district: district,
|
|
|
|
num_houses: num_houses,
|
|
|
|
phone: phone,
|
|
|
|
status: status,
|
|
|
|
date_entry: date_entry,
|
|
|
|
houses: houses,
|
2022-07-01 01:42:50 +00:00
|
|
|
};
|
2022-06-29 10:12:27 +00:00
|
|
|
return this.clientCommunityApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 10:12:27 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 01:42:50 +00:00
|
|
|
allCommunities() {
|
2022-06-29 10:12:27 +00:00
|
|
|
const pattern = { cmd: 'findAllCommunities' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientCommunityApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 10:12:27 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 01:42:50 +00:00
|
|
|
//GET parameter from API
|
|
|
|
findCommunity(paramCommunityId: string) {
|
2022-06-29 10:12:27 +00:00
|
|
|
const pattern = { cmd: 'findOneCommunity' };
|
2022-07-01 01:42:50 +00:00
|
|
|
const payload = { id: paramCommunityId };
|
2022-06-29 10:12:27 +00:00
|
|
|
return this.clientCommunityApp
|
2022-07-01 01:42:50 +00:00
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-06-29 10:12:27 +00:00
|
|
|
}
|
2022-07-01 07:39:52 +00:00
|
|
|
|
2022-07-15 03:16:02 +00:00
|
|
|
findCommunityName(paramCommunityId: string) {
|
|
|
|
const pattern = { cmd: 'findCommunityName' };
|
|
|
|
const payload = { id: paramCommunityId };
|
|
|
|
return this.clientCommunityApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-15 03:16:02 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 22:36:06 +00:00
|
|
|
|
|
|
|
async findHousesCommunity(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'];
|
|
|
|
const houses = response['houses'];
|
2022-08-22 22:39:20 +00:00
|
|
|
|
2022-08-16 22:36:06 +00:00
|
|
|
return houses;
|
|
|
|
}
|
|
|
|
|
2022-08-17 04:23:03 +00:00
|
|
|
saveTenant(id: string, number_house: string, tenant_id: string) {
|
|
|
|
const pattern = { cmd: 'saveTenant' };
|
|
|
|
const payload = { _id: id, number_house: number_house, tenant_id: tenant_id };
|
|
|
|
return this.clientCommunityApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
2022-08-22 22:39:20 +00:00
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== COMMON AREAS ===============================
|
2022-07-01 07:39:52 +00:00
|
|
|
//POST parameter from API
|
2022-07-25 04:38:48 +00:00
|
|
|
createCommonArea(
|
|
|
|
name: string,
|
|
|
|
hourMin: string,
|
|
|
|
hourMax: string,
|
|
|
|
bookable: number,
|
|
|
|
community_id: string,
|
|
|
|
) {
|
2022-07-01 07:39:52 +00:00
|
|
|
const pattern = { cmd: 'createCommonArea' };
|
|
|
|
const payload = {
|
2022-07-25 04:38:48 +00:00
|
|
|
name: name,
|
|
|
|
hourMin: hourMin,
|
|
|
|
hourMax: hourMax,
|
|
|
|
bookable: bookable,
|
|
|
|
community_id: community_id,
|
2022-08-02 06:13:09 +00:00
|
|
|
status: '1'
|
2022-07-01 07:39:52 +00:00
|
|
|
};
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allCommonAreas() {
|
|
|
|
const pattern = { cmd: 'findAllCommonAreas' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findCommonArea(paramCommonAreaId: string) {
|
|
|
|
const pattern = { cmd: 'findOneCommonArea' };
|
|
|
|
const payload = { id: paramCommonAreaId };
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 06:37:05 +00:00
|
|
|
|
2022-08-03 03:52:30 +00:00
|
|
|
//GET parameter from API
|
|
|
|
findByCommunity(paramCommunityId: string) {
|
2022-08-01 06:37:05 +00:00
|
|
|
const pattern = { cmd: 'findByCommunity' };
|
|
|
|
const payload = { community_id: paramCommunityId };
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
2022-08-01 07:08:27 +00:00
|
|
|
|
2022-08-03 03:52:30 +00:00
|
|
|
//DELETE parameter from API
|
|
|
|
deleteCommonArea(paramCommonAreaId: string) {
|
|
|
|
const pattern = { cmd: 'removeCommonArea' };
|
|
|
|
const payload = { id: paramCommonAreaId };
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
2022-08-01 07:08:27 +00:00
|
|
|
|
2022-08-19 06:19:15 +00:00
|
|
|
changeStatusCommonArea(pId: string, pStatus: string) {
|
|
|
|
const pattern = { cmd: 'changeStatus' };
|
|
|
|
const payload = { id: pId, status: pStatus };
|
|
|
|
return this.clientCommonAreaApp
|
|
|
|
.send<string>(pattern, payload)
|
|
|
|
.pipe(map((message: string) => ({ message })));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== GUESTS ===============================
|
2022-07-01 09:09:48 +00:00
|
|
|
|
|
|
|
//POST parameter from API
|
2022-07-25 04:38:48 +00:00
|
|
|
createGuest(
|
|
|
|
name: string,
|
|
|
|
last_name: string,
|
|
|
|
dni: string,
|
|
|
|
number_plate: string,
|
|
|
|
phone: number,
|
|
|
|
status: string,
|
|
|
|
date_entry: Date,
|
|
|
|
) {
|
2022-07-01 09:09:48 +00:00
|
|
|
const pattern = { cmd: 'createGuest' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
|
2022-07-01 09:09:48 +00:00
|
|
|
status: status, date_entry: date_entry
|
|
|
|
};
|
|
|
|
return this.clientGuestApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allGuests() {
|
|
|
|
const pattern = { cmd: 'findAllGuests' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientGuestApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findGuest(paramGuestDNI: string) {
|
|
|
|
const pattern = { cmd: 'findGuestDNI' };
|
|
|
|
const payload = { dni: paramGuestDNI };
|
|
|
|
return this.clientGuestApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:09:48 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 22:59:29 +00:00
|
|
|
// ====================== PAYMENTS ===============================
|
2022-07-01 09:48:27 +00:00
|
|
|
|
|
|
|
//POST parameter from API
|
2022-07-25 04:38:48 +00:00
|
|
|
createPayment(
|
|
|
|
date_payment: Date,
|
|
|
|
mount: number,
|
|
|
|
description: string,
|
|
|
|
period: string,
|
|
|
|
status: string,
|
|
|
|
user_id: string,
|
|
|
|
communty_id: string,
|
|
|
|
) {
|
2022-07-01 09:48:27 +00:00
|
|
|
const pattern = { cmd: 'createPayment' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
date_payment: date_payment, mount: mount, description: description,
|
|
|
|
period: period, status: status, user_id: user_id, communty_id: communty_id
|
2022-07-01 09:48:27 +00:00
|
|
|
};
|
|
|
|
return this.clientPaymentApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allPayments() {
|
|
|
|
const pattern = { cmd: 'findAllPayments' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientPaymentApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findPayment(paramPaymentId: string) {
|
|
|
|
const pattern = { cmd: 'findOnePayment' };
|
|
|
|
const payload = { id: paramPaymentId };
|
|
|
|
return this.clientPaymentApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 09:48:27 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== RESERVATIONS ===============================
|
2022-07-01 20:01:21 +00:00
|
|
|
|
|
|
|
//POST parameter from API
|
2022-07-26 22:59:29 +00:00
|
|
|
createReservation(start_time: string, finish_time: string, status: string,
|
2022-07-01 20:01:21 +00:00
|
|
|
date_entry: Date, user_id: string, common_area_id: string) {
|
|
|
|
const pattern = { cmd: 'createReservation' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
start_time: start_time, finish_time: finish_time, status: status,
|
|
|
|
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id
|
2022-07-01 20:01:21 +00:00
|
|
|
};
|
|
|
|
return this.clientReservationApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allReservations() {
|
|
|
|
const pattern = { cmd: 'findAllReservations' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientReservationApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findReservation(paramReservationId: string) {
|
|
|
|
const pattern = { cmd: 'findOneReservation' };
|
|
|
|
const payload = { id: paramReservationId };
|
|
|
|
return this.clientReservationApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:01:21 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== POSTS ===============================
|
2022-07-01 20:53:38 +00:00
|
|
|
|
|
|
|
//POST parameter from API
|
2022-07-26 22:59:29 +00:00
|
|
|
createPost(post: string, date_entry: Date, user_id: string,
|
2022-07-01 20:53:38 +00:00
|
|
|
community_id: string) {
|
|
|
|
const pattern = { cmd: 'createPost' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
post: post, date_entry: date_entry, user_id: user_id,
|
2022-07-01 20:53:38 +00:00
|
|
|
community_id: community_id
|
|
|
|
};
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allPosts() {
|
|
|
|
const pattern = { cmd: 'findAllPosts' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findPost(paramPostId: string) {
|
|
|
|
const pattern = { cmd: 'findOnePost' };
|
|
|
|
const payload = { id: paramPostId };
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
2022-07-01 20:01:21 +00:00
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== COMMNENT POSTS ===============================
|
2022-07-01 22:27:19 +00:00
|
|
|
|
|
|
|
//Comment parameter from API
|
2022-07-26 22:59:29 +00:00
|
|
|
createComment(comment: string, date_entry: Date, user_id: string,
|
2022-07-01 22:27:19 +00:00
|
|
|
post_id: string) {
|
|
|
|
const pattern = { cmd: 'createComment' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
comment: comment, date_entry: date_entry, user_id: user_id,
|
2022-07-01 22:27:19 +00:00
|
|
|
post_id: post_id
|
|
|
|
};
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 22:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allComments() {
|
|
|
|
const pattern = { cmd: 'findAllComments' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 22:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findComment(paramCommentId: string) {
|
|
|
|
const pattern = { cmd: 'findOneComment' };
|
|
|
|
const payload = { id: paramCommentId };
|
|
|
|
return this.clientPostApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 22:27:19 +00:00
|
|
|
}
|
2022-07-01 23:11:32 +00:00
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
// ====================== REPORTS ===============================
|
2022-07-01 23:11:32 +00:00
|
|
|
|
|
|
|
//Report parameter from API
|
2022-07-26 22:59:29 +00:00
|
|
|
createReport(action: string, description: string, date_entry: Date,
|
2022-07-01 23:11:32 +00:00
|
|
|
user_id: string) {
|
|
|
|
const pattern = { cmd: 'createReport' };
|
|
|
|
const payload = {
|
2022-07-26 22:59:29 +00:00
|
|
|
action: action, description: description, date_entry: date_entry,
|
2022-07-01 23:11:32 +00:00
|
|
|
user_id: user_id
|
|
|
|
};
|
|
|
|
return this.clientReportApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 23:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
allReports() {
|
|
|
|
const pattern = { cmd: 'findAllReports' };
|
|
|
|
const payload = {};
|
|
|
|
return this.clientReportApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 23:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//GET parameter from API
|
|
|
|
findReport(paramReportId: string) {
|
|
|
|
const pattern = { cmd: 'findOneReport' };
|
|
|
|
const payload = { id: paramReportId };
|
|
|
|
return this.clientReportApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-01 23:11:32 +00:00
|
|
|
}
|
2022-07-16 00:36:02 +00:00
|
|
|
|
|
|
|
sendMail(email: string) {
|
|
|
|
const pattern = { cmd: 'sendMail' };
|
2022-07-26 22:59:29 +00:00
|
|
|
const payload = { email: email };
|
2022-07-16 00:36:02 +00:00
|
|
|
return this.clientNotificationtApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-16 00:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
html(email: string, name: string) {
|
|
|
|
const pattern = { cmd: 'html' };
|
2022-07-26 22:59:29 +00:00
|
|
|
const payload = { email: email, name: name };
|
2022-07-16 00:36:02 +00:00
|
|
|
return this.clientNotificationtApp
|
|
|
|
.send<string>(pattern, payload)
|
2022-07-25 04:38:48 +00:00
|
|
|
.pipe(map((message: string) => ({ message })));
|
2022-07-16 00:36:02 +00:00
|
|
|
}
|
2022-07-26 22:59:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function to generate combination of password */
|
|
|
|
generatePassword() {
|
|
|
|
var pass = '';
|
|
|
|
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
|
|
|
|
'abcdefghijklmnopqrstuvwxyz0123456789@#$';
|
|
|
|
|
|
|
|
for (let i = 1; i <= 8; i++) {
|
|
|
|
var char = Math.floor(Math.random()
|
|
|
|
* str.length + 1);
|
|
|
|
|
|
|
|
pass += str.charAt(char)
|
|
|
|
}
|
|
|
|
|
|
|
|
return pass;
|
|
|
|
}
|
2022-07-25 04:38:48 +00:00
|
|
|
}
|