Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer #277

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#275 [Backend] New Spec 23042023
  • Loading branch information
fdhhhdjd committed Apr 24, 2023
commit 48ee329b9d1174e0fdd61be48ecdbbd1b7d4504d
Original file line number Diff line number Diff line change
@@ -115,8 +115,8 @@ const bookController = {
result_insert_book_categories === undefined
? null
: result_insert_book_categories
? MESSAGES.GENERAL.SERVER_INSERT_FAIL
: MESSAGES.GENERAL.SERVER_CURD_SUCCESS,
? MESSAGES.GENERAL.SERVER_INSERT_FAIL
: MESSAGES.GENERAL.SERVER_CURD_SUCCESS,
},
},
});
@@ -283,8 +283,8 @@ const bookController = {
result_insert_book_categories === undefined
? null
: result_insert_book_categories
? MESSAGES.GENERAL.SERVER_UPDATE_FAIL
: MESSAGES.GENERAL.SERVER_CURD_SUCCESS,
? MESSAGES.GENERAL.SERVER_UPDATE_FAIL
: MESSAGES.GENERAL.SERVER_CURD_SUCCESS,
},
},
});
24 changes: 12 additions & 12 deletions backend-manager-student/src/share/middleware/handle_error.js
Original file line number Diff line number Diff line change
@@ -28,18 +28,18 @@ module.exports = {
const constraint = error.constraint;
let message;
switch (constraint) {
case KEY_DUPLICATE.DUPLICATE_KEY_EMAIL:
message = MESSAGES.GENERAL.EXITS_EMAIL;
break;
case KEY_DUPLICATE.DUPLICATE_KEY_PHONE:
message = MESSAGES.GENERAL.EXITS_PHONE;
break;
case KEY_DUPLICATE.DUPLICATE_KEY_MSSV:
message = MESSAGES.GENERAL.EXITS_MSSV;
break;
default:
message = MESSAGES.GENERAL.ERROR_UNKNOWN;
break;
case KEY_DUPLICATE.DUPLICATE_KEY_EMAIL:
message = MESSAGES.GENERAL.EXITS_EMAIL;
break;
case KEY_DUPLICATE.DUPLICATE_KEY_PHONE:
message = MESSAGES.GENERAL.EXITS_PHONE;
break;
case KEY_DUPLICATE.DUPLICATE_KEY_MSSV:
message = MESSAGES.GENERAL.EXITS_MSSV;
break;
default:
message = MESSAGES.GENERAL.ERROR_UNKNOWN;
break;
}
return message;
},
3 changes: 1 addition & 2 deletions backend-manager-student/src/share/models/author.model.js
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ module.exports = {
createAuthor: (data) =>
new Promise((resolve, reject) => {
try {
const result = knex('authors').insert(data).onConflict('author_id').merge()
.returning(['author_id']);
const result = knex('authors').insert(data).onConflict('author_id').merge().returning(['author_id']);
resolve(result);
} catch (error) {
reject(error);
3 changes: 1 addition & 2 deletions backend-manager-student/src/share/models/book.model.js
Original file line number Diff line number Diff line change
@@ -13,8 +13,7 @@ module.exports = {
createBook: (data) =>
new Promise((resolve, reject) => {
try {
const result = knex('books').insert(data).onConflict('book_id').merge()
.returning(['book_id']);
const result = knex('books').insert(data).onConflict('book_id').merge().returning(['book_id']);
resolve(result);
} catch (error) {
reject(error);
3 changes: 1 addition & 2 deletions backend-manager-student/src/share/models/phone.model.js
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ module.exports = {
createPhone: (data) =>
new Promise((resolve, reject) => {
try {
const result = knex('phone').insert(data).onConflict('phone_id').merge()
.returning(['phone_id']);
const result = knex('phone').insert(data).onConflict('phone_id').merge().returning(['phone_id']);
resolve(result);
} catch (error) {
reject(error);
3 changes: 1 addition & 2 deletions backend-manager-student/src/share/models/rating.model.js
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ module.exports = {
createRatings: (data) =>
new Promise((resolve, reject) => {
try {
const result = knex('book_rates').insert(data).onConflict('rate_id').merge()
.returning(['rate_id']);
const result = knex('book_rates').insert(data).onConflict('rate_id').merge().returning(['rate_id']);
resolve(result);
} catch (error) {
reject(error);
3 changes: 1 addition & 2 deletions backend-manager-student/src/share/models/user.model.js
Original file line number Diff line number Diff line change
@@ -119,8 +119,7 @@ module.exports = {
createStudent: (data) =>
new Promise((resolve, reject) => {
try {
const result_student = knex('user').insert(data).onConflict('user_id').merge()
.returning(['user_id']);
const result_student = knex('user').insert(data).onConflict('user_id').merge().returning(['user_id']);
resolve(result_student);
} catch (error) {
reject(error);
30 changes: 15 additions & 15 deletions backend-manager-student/src/share/utils/redis_pub_sub_helper.js
Original file line number Diff line number Diff line change
@@ -74,21 +74,21 @@ const handleException = (err, name, port) => {
});
let message_queue;
switch (name) {
case CONSTANTS.NAME_SERVER.STUDENT:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_STUDENT;
break;
case CONSTANTS.NAME_SERVER.ADMIN:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_ADMIN;
break;
case CONSTANTS.NAME_SERVER.CRON:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_CRON;
break;
case CONSTANTS.NAME_SERVER.DB:
message_queue = CONSTANTS.QUEUE.REDIS_DB;
break;
default:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_CRON;
break;
case CONSTANTS.NAME_SERVER.STUDENT:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_STUDENT;
break;
case CONSTANTS.NAME_SERVER.ADMIN:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_ADMIN;
break;
case CONSTANTS.NAME_SERVER.CRON:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_CRON;
break;
case CONSTANTS.NAME_SERVER.DB:
message_queue = CONSTANTS.QUEUE.REDIS_DB;
break;
default:
message_queue = CONSTANTS.QUEUE.REDIS_SERVER_CRON;
break;
}
// Publish data queue Redis
return queueMessageTelegram(message_queue, {
Original file line number Diff line number Diff line change
@@ -272,8 +272,8 @@ paths:
type: number
example: 1551993628342091778
required:
- book_id
- slug
- book_id
- slug
responses:
200:
description: success