add service and controller functions to update post

This commit is contained in:
Eduardo Quiros 2022-08-30 05:56:59 -06:00
parent 0ed28237aa
commit b840ebe654
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
2 changed files with 26 additions and 6 deletions

View File

@ -468,7 +468,7 @@ export class AppController {
} }
// #==== API Reservation // #==== API Reservation
@ -516,7 +516,7 @@ export class AppController {
return this.appService.deleteReservation(id); return this.appService.deleteReservation(id);
} }
// #==== API Post // #==== API Post
@Post('post/createPost') @Post('post/createPost')
@ -529,6 +529,16 @@ export class AppController {
return this.appService.createPost(post, date_entry, user_id, community_id); return this.appService.createPost(post, date_entry, user_id, community_id);
} }
@Put('post/updatePost/:id')
updatePost(
@Param('id') id: string,
@Body('post') post: string,
@Body('user_id') user_id: string,
@Body('community_id') community_id: string,
) {
return this.appService.updatePost(id, post, user_id, community_id);
}
@Get('post/allPosts') @Get('post/allPosts')
allPosts() { allPosts() {
return this.appService.allPosts(); return this.appService.allPosts();

View File

@ -540,7 +540,7 @@ export class AppService {
const pattern = { cmd: 'createGuest' }; const pattern = { cmd: 'createGuest' };
const payload = { const payload = {
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone, name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
status: status,tenant_id:tenant_id, community_id:community_id,date_entry: date_entry status: status, tenant_id: tenant_id, community_id: community_id, date_entry: date_entry
}; };
return this.clientGuestApp return this.clientGuestApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
@ -571,17 +571,17 @@ export class AppService {
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
// ====================== RESERVATIONS =============================== // ====================== RESERVATIONS ===============================
//POST parameter from API //POST parameter from API
createReservation(date: string, time: string, status: string, createReservation(date: string, time: string, status: string,
date_entry: Date, user_id: string, common_area_id: string, date_entry: Date, user_id: string, common_area_id: string,
common_area_name: string, community_id: string) { common_area_name: string, community_id: string) {
const pattern = { cmd: 'createReservation' }; const pattern = { cmd: 'createReservation' };
const payload = { const payload = {
date: date, time: time, status: status, date: date, time: time, status: status,
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id, date_entry: date_entry, user_id: user_id, common_area_id: common_area_id,
common_area_name: common_area_name, community_id: community_id common_area_name: common_area_name, community_id: community_id
}; };
return this.clientReservationApp return this.clientReservationApp
@ -638,6 +638,16 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
updatePost(id: string, post: string, user_id: string, community_id: string) {
const pattern = { cmd: 'updatePost' };
const payload = {
post: post, id: id, user_id: user_id, community_id: community_id
};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
allPosts() { allPosts() {
const pattern = { cmd: 'findAllPosts' }; const pattern = { cmd: 'findAllPosts' };
const payload = {}; const payload = {};