2022-07-22 07:22:13 +00:00
|
|
|
import { Controller, Get, Post, Body, Param, Delete } from '@nestjs/common';
|
2022-07-25 04:38:48 +00:00
|
|
|
import { AppService } from './app.service';
|
2022-06-29 02:30:10 +00:00
|
|
|
@Controller()
|
|
|
|
export class AppController {
|
2022-07-25 04:38:48 +00:00
|
|
|
constructor(private readonly appService: AppService) {}
|
2022-07-01 20:53:38 +00:00
|
|
|
// #==== API Users
|
2022-07-01 01:42:50 +00:00
|
|
|
@Post('user/createAdminSystem')
|
|
|
|
createAdminSystem(
|
|
|
|
@Body('dni') dni: string,
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('last_name') last_name: string,
|
|
|
|
@Body('email') email: string,
|
|
|
|
@Body('phone') phone: number,
|
|
|
|
@Body('user_type') user_type: string,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
) {
|
2022-07-26 22:59:29 +00:00
|
|
|
return this.appService.createAdminSystem(dni, name, last_name, email, phone,
|
|
|
|
user_type, status, date_entry);
|
2022-07-01 01:42:50 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 02:55:01 +00:00
|
|
|
@Post('user/createGuard')
|
|
|
|
createGuard(
|
|
|
|
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña
|
|
|
|
@Body('dni') dni: string,
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('last_name') last_name: string,
|
|
|
|
@Body('email') email: string,
|
|
|
|
@Body('phone') phone: number,
|
|
|
|
@Body('user_type') user_type: string,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
2022-07-25 04:38:48 +00:00
|
|
|
@Body('community_id') community_id: string,
|
2022-07-19 02:55:01 +00:00
|
|
|
) {
|
2022-07-26 22:59:29 +00:00
|
|
|
return this.appService.createGuard(dni, name, last_name, email, phone,
|
|
|
|
user_type, status, date_entry,community_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Post('user/createAdminCommunity')
|
|
|
|
createAdminCommunity(
|
|
|
|
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña
|
|
|
|
@Body('dni') dni: string,
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('last_name') last_name: string,
|
|
|
|
@Body('email') email: string,
|
|
|
|
@Body('phone') phone: number,
|
|
|
|
@Body('user_type') user_type: string,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
@Body('community_id') community_id:string
|
|
|
|
) {
|
|
|
|
return this.appService.createAdminCommunity(dni, name, last_name, email, phone,
|
2022-07-19 03:33:36 +00:00
|
|
|
user_type, status, date_entry,community_id);
|
2022-07-19 02:55:01 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 07:39:52 +00:00
|
|
|
@Post('user/createUser')
|
2022-06-29 09:23:07 +00:00
|
|
|
createUser(
|
|
|
|
@Body('dni') dni: string,
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('last_name') last_name: string,
|
|
|
|
@Body('email') email: string,
|
|
|
|
@Body('phone') phone: number,
|
|
|
|
@Body('password') password: string,
|
|
|
|
@Body('user_type') user_type: string,
|
2022-06-29 10:12:27 +00:00
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
2022-07-01 01:42:50 +00:00
|
|
|
@Body('community_id') community_id: string,
|
2022-06-29 09:23:07 +00:00
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createUser(
|
|
|
|
dni,
|
|
|
|
name,
|
|
|
|
last_name,
|
|
|
|
email,
|
|
|
|
phone,
|
|
|
|
password,
|
|
|
|
user_type,
|
|
|
|
status,
|
|
|
|
date_entry,
|
|
|
|
community_id,
|
|
|
|
);
|
2022-06-29 02:30:10 +00:00
|
|
|
}
|
2022-06-29 09:23:07 +00:00
|
|
|
|
2022-07-01 07:39:52 +00:00
|
|
|
@Get('user/allUsers')
|
2022-06-29 09:23:07 +00:00
|
|
|
allUsers() {
|
|
|
|
return this.appService.allUsers();
|
|
|
|
}
|
|
|
|
|
2022-07-11 02:22:34 +00:00
|
|
|
@Post('user/loginUser')
|
|
|
|
inicioSesion(
|
|
|
|
@Body('email') pEmail: string,
|
|
|
|
@Body('password') pPassword: string,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.inicioSesion(pEmail, pPassword);
|
2022-07-11 02:22:34 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 01:01:02 +00:00
|
|
|
@Get('user/findAdminSistema')
|
|
|
|
allUsersAdminSistema() {
|
|
|
|
return this.appService.allUsersAdminSistema();
|
|
|
|
}
|
|
|
|
|
2022-07-15 03:16:02 +00:00
|
|
|
@Get('user/findAdminComunidad')
|
|
|
|
allUsersAdminComunidad() {
|
|
|
|
return this.appService.allUsersAdminComunidad();
|
|
|
|
}
|
2022-07-19 04:28:56 +00:00
|
|
|
@Get('user/findGuards/:community')
|
2022-07-25 04:38:48 +00:00
|
|
|
findGuardsCommunity(@Param('community_id') community_id: string) {
|
2022-07-19 04:28:56 +00:00
|
|
|
return this.appService.findGuardsCommunity(community_id);
|
|
|
|
}
|
2022-07-15 03:16:02 +00:00
|
|
|
|
2022-06-29 10:12:27 +00:00
|
|
|
@Get('user/find/:dni')
|
2022-07-25 04:38:48 +00:00
|
|
|
findUser(@Param('dni') paramUserDNI: string) {
|
2022-06-29 10:12:27 +00:00
|
|
|
return this.appService.findUser(paramUserDNI);
|
|
|
|
}
|
|
|
|
|
2022-07-22 07:22:13 +00:00
|
|
|
@Delete('user/deleteAdminSystem/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
deleteAdminSystem(@Param('id') id: string) {
|
2022-07-22 07:22:13 +00:00
|
|
|
return this.appService.deleteAdminSystem(id);
|
|
|
|
}
|
|
|
|
|
2022-07-01 07:39:52 +00:00
|
|
|
// #==== API Communities
|
2022-06-29 10:12:27 +00:00
|
|
|
@Post('community/createCommunity')
|
|
|
|
createCommunity(
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('province') province: string,
|
|
|
|
@Body('canton') canton: string,
|
|
|
|
@Body('district') district: string,
|
|
|
|
@Body('num_houses') num_houses: number,
|
2022-07-21 10:27:39 +00:00
|
|
|
@Body('phone') phone: string,
|
2022-06-29 10:12:27 +00:00
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
2022-07-21 10:27:39 +00:00
|
|
|
@Body('houses') houses: [],
|
2022-06-29 10:12:27 +00:00
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createCommunity(
|
|
|
|
name,
|
|
|
|
province,
|
|
|
|
canton,
|
|
|
|
district,
|
|
|
|
num_houses,
|
|
|
|
phone,
|
|
|
|
status,
|
|
|
|
date_entry,
|
|
|
|
houses,
|
|
|
|
);
|
2022-06-29 10:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('community/allCommunities')
|
|
|
|
allcommunities() {
|
|
|
|
return this.appService.allCommunities();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('community/findCommunity/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findCommunity(@Param('id') paramCommunityId: string) {
|
2022-06-29 10:12:27 +00:00
|
|
|
return this.appService.findCommunity(paramCommunityId);
|
|
|
|
}
|
2022-07-01 07:39:52 +00:00
|
|
|
|
2022-07-15 03:16:02 +00:00
|
|
|
@Get('community/findCommunityName/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findCommunityName(@Param('id') paramCommunityId: string) {
|
2022-07-15 03:16:02 +00:00
|
|
|
return this.appService.findCommunityName(paramCommunityId);
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:56:48 +00:00
|
|
|
@Post('community/findCommunityAdmin')
|
2022-07-25 04:38:48 +00:00
|
|
|
findCommunityAdmin(@Body('community_id') community_id: string) {
|
2022-07-19 19:56:48 +00:00
|
|
|
return this.appService.findCommunityAdmin(community_id);
|
|
|
|
}
|
|
|
|
|
2022-07-01 07:39:52 +00:00
|
|
|
// #==== API Common Areas
|
|
|
|
@Post('commonArea/createCommonArea')
|
|
|
|
createCommonArea(
|
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('hourMin') hourMin: string,
|
|
|
|
@Body('hourMax') hourMax: string,
|
|
|
|
@Body('bookable') bookable: number,
|
|
|
|
@Body('community_id') community_id: string,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createCommonArea(
|
|
|
|
name,
|
|
|
|
hourMin,
|
|
|
|
hourMax,
|
|
|
|
bookable,
|
|
|
|
community_id,
|
|
|
|
);
|
2022-07-01 07:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('commonArea/allCommonAreas')
|
|
|
|
allCommonAreas() {
|
|
|
|
return this.appService.allCommonAreas();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('commonArea/findCommonArea/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findCommonArea(@Param('id') paramCommonAreaId: string) {
|
2022-07-01 07:39:52 +00:00
|
|
|
return this.appService.findCommonArea(paramCommonAreaId);
|
|
|
|
}
|
2022-07-01 09:09:48 +00:00
|
|
|
|
2022-08-01 06:37:05 +00:00
|
|
|
@Get('commonArea//findByCommunity/:community_id')
|
|
|
|
findByCommunity(@Param('community_id') paramCommunityId: string) {
|
|
|
|
return this.appService.findByCommunity(paramCommunityId);
|
|
|
|
}
|
|
|
|
|
2022-07-01 09:48:27 +00:00
|
|
|
// #==== API GUEST
|
2022-07-01 09:09:48 +00:00
|
|
|
//#API userService - create user
|
|
|
|
@Post('guest/createGuest')
|
2022-07-01 09:48:27 +00:00
|
|
|
createGuest(
|
2022-07-01 09:09:48 +00:00
|
|
|
@Body('name') name: string,
|
|
|
|
@Body('last_name') last_name: string,
|
|
|
|
@Body('dni') dni: string,
|
|
|
|
@Body('number_plate') number_plate: string,
|
|
|
|
@Body('phone') phone: number,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createGuest(
|
|
|
|
name,
|
|
|
|
last_name,
|
|
|
|
dni,
|
|
|
|
number_plate,
|
|
|
|
phone,
|
|
|
|
status,
|
|
|
|
date_entry,
|
|
|
|
);
|
2022-07-01 09:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('guest/allGuests')
|
|
|
|
allGuests() {
|
|
|
|
return this.appService.allGuests();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('guest/find/:dni')
|
2022-07-25 04:38:48 +00:00
|
|
|
findGuest(@Param('dni') paramGuestDNI: string) {
|
2022-07-01 09:09:48 +00:00
|
|
|
return this.appService.findGuest(paramGuestDNI);
|
|
|
|
}
|
2022-07-01 09:48:27 +00:00
|
|
|
|
|
|
|
// #==== API Payment
|
2022-07-01 20:53:38 +00:00
|
|
|
|
2022-07-01 09:48:27 +00:00
|
|
|
@Post('payment/createPayment')
|
|
|
|
createPayment(
|
|
|
|
@Body('date_payment') date_payment: Date,
|
|
|
|
@Body('mount') mount: number,
|
|
|
|
@Body('description') description: string,
|
|
|
|
@Body('period') period: string,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('user_id') user_id: string,
|
|
|
|
@Body('communty_id') communty_id: string,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createPayment(
|
|
|
|
date_payment,
|
|
|
|
mount,
|
|
|
|
description,
|
|
|
|
period,
|
|
|
|
status,
|
|
|
|
user_id,
|
|
|
|
communty_id,
|
|
|
|
);
|
2022-07-01 09:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('payment/allPayments')
|
|
|
|
allPayments() {
|
|
|
|
return this.appService.allPayments();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('payment/find/:dni')
|
2022-07-25 04:38:48 +00:00
|
|
|
findPayment(@Param('dni') paramPaymentDNI: string) {
|
2022-07-01 09:48:27 +00:00
|
|
|
return this.appService.findPayment(paramPaymentDNI);
|
|
|
|
}
|
2022-07-01 20:01:21 +00:00
|
|
|
|
2022-07-01 20:53:38 +00:00
|
|
|
// #==== API Reservation
|
|
|
|
|
2022-07-01 20:01:21 +00:00
|
|
|
@Post('reservation/createReservation')
|
|
|
|
createReservation(
|
|
|
|
@Body('start_time') start_time: string,
|
|
|
|
@Body('finish_time') finish_time: string,
|
|
|
|
@Body('status') status: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
@Body('user_id') user_id: string,
|
|
|
|
@Body('common_area_id') common_area_id: string,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createReservation(
|
|
|
|
start_time,
|
|
|
|
finish_time,
|
|
|
|
status,
|
|
|
|
date_entry,
|
|
|
|
user_id,
|
|
|
|
common_area_id,
|
|
|
|
);
|
2022-07-01 20:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('reservation/allReservations')
|
|
|
|
allReservations() {
|
|
|
|
return this.appService.allReservations();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('reservation/find/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findReservation(@Param('id') paramReservation: string) {
|
2022-07-01 20:01:21 +00:00
|
|
|
return this.appService.findReservation(paramReservation);
|
|
|
|
}
|
2022-07-01 20:53:38 +00:00
|
|
|
|
|
|
|
// #==== API Post
|
|
|
|
|
|
|
|
@Post('post/createPost')
|
|
|
|
createPost(
|
|
|
|
@Body('post') post: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
@Body('user_id') user_id: string,
|
|
|
|
@Body('community_id') community_id: string,
|
|
|
|
) {
|
|
|
|
return this.appService.createPost(post, date_entry, user_id, community_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('post/allPosts')
|
|
|
|
allPosts() {
|
|
|
|
return this.appService.allPosts();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('post/find/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findPost(@Param('id') paramPost: string) {
|
2022-07-01 20:53:38 +00:00
|
|
|
return this.appService.findPost(paramPost);
|
|
|
|
}
|
2022-07-01 22:27:19 +00:00
|
|
|
|
|
|
|
// #==== API Comment
|
|
|
|
|
|
|
|
@Post('post/createComment')
|
|
|
|
createComment(
|
|
|
|
@Body('comment') comment: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
@Body('user_id') user_id: string,
|
|
|
|
@Body('post_id') post_id: string,
|
|
|
|
) {
|
|
|
|
return this.appService.createComment(comment, date_entry, user_id, post_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('post/allComments')
|
|
|
|
allComments() {
|
|
|
|
return this.appService.allComments();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('post/findComment/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findComment(@Param('id') paramComment: string) {
|
2022-07-01 22:27:19 +00:00
|
|
|
return this.appService.findComment(paramComment);
|
|
|
|
}
|
2022-07-01 23:11:32 +00:00
|
|
|
|
|
|
|
// #==== API Report
|
|
|
|
|
|
|
|
@Post('report/createReport')
|
|
|
|
createReport(
|
|
|
|
@Body('action') action: string,
|
|
|
|
@Body('description') description: string,
|
|
|
|
@Body('date_entry') date_entry: Date,
|
|
|
|
@Body('user_id') user_id: string,
|
|
|
|
) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.appService.createReport(
|
|
|
|
action,
|
|
|
|
description,
|
|
|
|
date_entry,
|
|
|
|
user_id,
|
|
|
|
);
|
2022-07-01 23:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Get('report/allReports')
|
|
|
|
allReports() {
|
|
|
|
return this.appService.allReports();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Get('report/find/:id')
|
2022-07-25 04:38:48 +00:00
|
|
|
findReport(@Param('id') paramReport: string) {
|
2022-07-01 23:11:32 +00:00
|
|
|
return this.appService.findReport(paramReport);
|
|
|
|
}
|
2022-07-16 00:36:02 +00:00
|
|
|
|
|
|
|
@Post('email/sendMail')
|
2022-07-25 04:38:48 +00:00
|
|
|
senMail(@Body('email') email: string) {
|
2022-07-16 00:36:02 +00:00
|
|
|
return this.appService.sendMail(email);
|
|
|
|
}
|
|
|
|
@Post('email/html')
|
2022-07-25 04:38:48 +00:00
|
|
|
html(@Body('email') email: string, @Body('name') name: string) {
|
2022-07-16 00:36:02 +00:00
|
|
|
return this.appService.html(email, name);
|
|
|
|
}
|
2022-07-25 04:38:48 +00:00
|
|
|
}
|