Compare commits
3 Commits
f87aecaf75
...
3525fb12e6
| Author | SHA1 | Date | |
|---|---|---|---|
| 3525fb12e6 | |||
| 82afff9878 | |||
| fef2bda082 |
@ -12,7 +12,7 @@ RentRouter.route("/affected").get(UserGuard);
|
|||||||
RentRouter.route("/affected/all").get(AdminGuard);
|
RentRouter.route("/affected/all").get(AdminGuard);
|
||||||
|
|
||||||
// Add a new vehicle (admin only)
|
// Add a new vehicle (admin only)
|
||||||
RentRouter.route("/veh/new").post(AdminGuard);
|
RentRouter.route("/veh/new").post(AdminGuard, VehicleController.create);
|
||||||
|
|
||||||
// Get all vehicles
|
// Get all vehicles
|
||||||
RentRouter.route("/veh/all").get(VehicleController.getAll);
|
RentRouter.route("/veh/all").get(VehicleController.getAll);
|
||||||
|
|||||||
@ -228,9 +228,7 @@ const MySqlService = {
|
|||||||
actionName: "Update user..",
|
actionName: "Update user..",
|
||||||
})
|
})
|
||||||
.then((factorizeResult) => {
|
.then((factorizeResult) => {
|
||||||
const _sql = `UPDATE users SET (${factorizeResult._keysTemplate}) WERE id VALUES(${
|
const _sql = `UPDATE users SET (${factorizeResult._keysTemplate}) WERE id VALUES(${factorizeResult._questionMarksFields})`;
|
||||||
factorizeResult._questionMarksFields
|
|
||||||
})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -432,9 +430,7 @@ const MySqlService = {
|
|||||||
actionName: "Update brand..",
|
actionName: "Update brand..",
|
||||||
})
|
})
|
||||||
.then((factorizeResult) => {
|
.then((factorizeResult) => {
|
||||||
const _sql = `UPDATE brands SET (${factorizeResult._keysTemplate}) WERE id VALUES(${
|
const _sql = `UPDATE brands SET (${factorizeResult._keysTemplate}) WERE id VALUES(${factorizeResult._questionMarksFields})`;
|
||||||
factorizeResult._questionMarksFields
|
|
||||||
})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -672,9 +668,7 @@ const MySqlService = {
|
|||||||
actionName: "Update model..",
|
actionName: "Update model..",
|
||||||
})
|
})
|
||||||
.then((factorizeResult) => {
|
.then((factorizeResult) => {
|
||||||
const _sql = `UPDATE models SET (${factorizeResult._keysTemplate}) WERE id VALUES(${
|
const _sql = `UPDATE models SET (${factorizeResult._keysTemplate}) WERE id VALUES(${factorizeResult._questionMarksFields})`;
|
||||||
factorizeResult._questionMarksFields
|
|
||||||
})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -778,9 +772,7 @@ const MySqlService = {
|
|||||||
actionName: "Update vehicle..",
|
actionName: "Update vehicle..",
|
||||||
})
|
})
|
||||||
.then((factorizeResult) => {
|
.then((factorizeResult) => {
|
||||||
const _sql = `UPDATE vehicles SET (${factorizeResult._keysTemplate}) WERE id VALUES(${
|
const _sql = `UPDATE vehicles SET (${factorizeResult._keysTemplate}) WERE id VALUES(${factorizeResult._questionMarksFields})`;
|
||||||
factorizeResult._questionMarksFields
|
|
||||||
})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -903,9 +895,9 @@ const MySqlService = {
|
|||||||
.then((factorizedResult) => {
|
.then((factorizedResult) => {
|
||||||
const valuesArray = factorizedResult._valuesArray;
|
const valuesArray = factorizedResult._valuesArray;
|
||||||
const template = factorizedResult._keysTemplate;
|
const template = factorizedResult._keysTemplate;
|
||||||
const _sql = `INSERT INTO categories (${template + `, id`}) VALUES(${
|
const _sql = `INSERT INTO categories (${
|
||||||
factorizedResult._questionMarksFields
|
template + `, id`
|
||||||
})`;
|
}) VALUES(${factorizedResult._questionMarksFields})`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -939,9 +931,7 @@ const MySqlService = {
|
|||||||
actionName: "Update brand..",
|
actionName: "Update brand..",
|
||||||
})
|
})
|
||||||
.then((factorizeResult) => {
|
.then((factorizeResult) => {
|
||||||
const _sql = `UPDATE categories SET (${factorizeResult._keysTemplate}) WERE id VALUES(${
|
const _sql = `UPDATE categories SET (${factorizeResult._keysTemplate}) WERE id VALUES(${factorizeResult._questionMarksFields})`;
|
||||||
factorizeResult._questionMarksFields
|
|
||||||
})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDebugMode()) handler.Logger.trace(_sql);
|
if (isDebugMode()) handler.Logger.trace(_sql);
|
||||||
@ -1066,7 +1056,10 @@ const MySqlService = {
|
|||||||
* @param {string} categoryId - The ID of the category.
|
* @param {string} categoryId - The ID of the category.
|
||||||
* @return {Promise<Array<IDbModel>>} - A promise that resolves to an array of database models belonging to the specified category.
|
* @return {Promise<Array<IDbModel>>} - A promise that resolves to an array of database models belonging to the specified category.
|
||||||
*/
|
*/
|
||||||
getAllModelsFromCategory(handler: MysqlHandler, categoryId: string): Promise<Array<IDbModel>> {
|
getAllModelsFromCategory(
|
||||||
|
handler: MysqlHandler,
|
||||||
|
categoryId: string,
|
||||||
|
): Promise<Array<IDbModel>> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const _sql =
|
const _sql =
|
||||||
"SELECT models.* FROM models INNER JOIN categories ON models.category_id = categories.id WHERE categories.id VALUES(?)";
|
"SELECT models.* FROM models INNER JOIN categories ON models.category_id = categories.id WHERE categories.id VALUES(?)";
|
||||||
@ -1079,7 +1072,6 @@ const MySqlService = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
Rent: {
|
Rent: {
|
||||||
//ToTest
|
//ToTest
|
||||||
@ -1143,6 +1135,7 @@ const MySqlService = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//ToTest
|
||||||
/**
|
/**
|
||||||
* Retrieves all assigned vehicles from the database.
|
* Retrieves all assigned vehicles from the database.
|
||||||
*
|
*
|
||||||
@ -1164,6 +1157,16 @@ const MySqlService = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//ToTest
|
||||||
|
/**
|
||||||
|
* Updates a rent record in the database.
|
||||||
|
*
|
||||||
|
* @param {MysqlHandler} handler - The database handler object.
|
||||||
|
* @param {IDbRent} data - The rent object containing the updated data.
|
||||||
|
* @returns {Promise<IDbStatusResult>} - A promise that resolves to the status result of the update operation.
|
||||||
|
* @throws {Error} - If an error occurs during the update operation.
|
||||||
|
*/
|
||||||
update(handler: MysqlHandler, data: IDbRent): Promise<IDbStatusResult> {
|
update(handler: MysqlHandler, data: IDbRent): Promise<IDbStatusResult> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!data.id) return reject("Id is undefined");
|
if (!data.id) return reject("Id is undefined");
|
||||||
@ -1197,10 +1200,7 @@ const MySqlService = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
delete(
|
delete(handler: MysqlHandler, rentId: string): Promise<IDbStatusResult> {
|
||||||
handler: MysqlHandler,
|
|
||||||
rentId: string,
|
|
||||||
): Promise<IDbStatusResult> {
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!rentId) return reject("Id is undefined");
|
if (!rentId) return reject("Id is undefined");
|
||||||
if (rentId.length !== 36) return reject("Id invalid");
|
if (rentId.length !== 36) return reject("Id invalid");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user