repair: body message wa in notif

This commit is contained in:
2026-01-06 14:37:52 +07:00
parent 6f4d171537
commit b025c5ea82
4 changed files with 161 additions and 94 deletions

View File

@@ -1,14 +1,28 @@
const NotificationErrorUserService = require('../services/notification_error_user.service');
const { setResponse, setResponsePaging, checkValidate } = require('../helpers/utils');
const { insertNotificationErrorUserSchema, updateNotificationErrorUserSchema } = require('../validate/notification_error_user.schema');
const NotificationErrorUserService = require("../services/notification_error_user.service");
const {
setResponse,
setResponsePaging,
checkValidate,
} = require("../helpers/utils");
const {
insertNotificationErrorUserSchema,
updateNotificationErrorUserSchema,
} = require("../validate/notification_error_user.schema");
class NotificationErrorUserController {
// Get all NotificationErrorUser
static async getAll(req, res) {
const queryParams = req.query;
const results = await NotificationErrorUserService.getAllNotificationErrorUser(queryParams);
const response = await setResponsePaging(queryParams, results, 'Notification Error User found')
const results =
await NotificationErrorUserService.getAllNotificationErrorUser(
queryParams
);
const response = await setResponsePaging(
queryParams,
results,
"Notification Error User found"
);
res.status(response.statusCode).json(response);
}
@@ -17,24 +31,35 @@ class NotificationErrorUserController {
static async getById(req, res) {
const { id } = req.params;
const results = await NotificationErrorUserService.getNotificationErrorUserById(id);
const response = await setResponse(results, 'Notification Error User found')
const results =
await NotificationErrorUserService.getNotificationErrorUserById(id);
const response = await setResponse(
results,
"Notification Error User found"
);
res.status(response.statusCode).json(response);
}
// Create NotificationErrorUser
static async create(req, res) {
const { error, value } = await checkValidate(insertNotificationErrorUserSchema, req)
const { error, value } = await checkValidate(
insertNotificationErrorUserSchema,
req
);
if (error) {
return res.status(400).json(setResponse(error, 'Validation failed', 400));
return res.status(400).json(setResponse(error, "Validation failed", 400));
}
value.userId = req.user.user_id
value.userId = req.user.user_id;
const results = await NotificationErrorUserService.createNotificationErrorUser(value);
const response = await setResponse(results, 'Notification Error User created successfully')
const results =
await NotificationErrorUserService.createNotificationErrorUser(value);
const response = await setResponse(
results,
"Notification Error User created successfully"
);
return res.status(response.statusCode).json(response);
}
@@ -43,16 +68,23 @@ class NotificationErrorUserController {
static async update(req, res) {
const { id } = req.params;
const { error, value } = checkValidate(updateNotificationErrorUserSchema, req)
const { error, value } = checkValidate(
updateNotificationErrorUserSchema,
req
);
if (error) {
return res.status(400).json(setResponse(error, 'Validation failed', 400));
return res.status(400).json(setResponse(error, "Validation failed", 400));
}
value.userId = req.user.user_id
value.userId = req.user.user_id;
const results = await NotificationErrorUserService.updateNotificationErrorUser(id, value);
const response = await setResponse(results, 'Notification Error User updated successfully')
const results =
await NotificationErrorUserService.updateNotificationErrorUser(id, value);
const response = await setResponse(
results,
"Notification Error User updated successfully"
);
res.status(response.statusCode).json(response);
}
@@ -61,27 +93,30 @@ class NotificationErrorUserController {
static async delete(req, res) {
const { id } = req.params;
const results = await NotificationErrorUserService.deleteNotificationErrorUser(id, req.user.user_id);
const response = await setResponse(results, 'Notification Error User deleted successfully')
const results =
await NotificationErrorUserService.deleteNotificationErrorUser(
id,
req.user.user_id
);
const response = await setResponse(
results,
"Notification Error User deleted successfully"
);
res.status(response.statusCode).json(response);
}
static async resendByUser(req, res) {
try {
const { id, contact_phone } = req.params;
const results = await NotificationErrorUserService.resendNotificationByUser(id, contact_phone)
const response = await setResponse(
results,
results.message,
);
res.status(response.statusCode).json(response);
const result =
await NotificationErrorUserService.resendNotificationByUser(
id,
contact_phone
);
res.status(200).json(result);
} catch (error) {
const response = setResponse(null, error.message, error.statusCode || 500);
res.status(response.statusCode).json(response);
return error;
}
}
}