fix: crud user

This commit is contained in:
2025-10-11 02:26:17 +07:00
parent 751cd0911e
commit e581f5b5bb
5 changed files with 154 additions and 156 deletions

View File

@@ -132,6 +132,22 @@ const updateUserDb = async (userId, data) => {
return getUserByIdDb(userId);
};
const approveUserDb = async (userId, approverId) => {
const queryText = `
UPDATE m_users
SET
is_approve = 1,
approved_by = $1,
approved_at = CURRENT_TIMESTAMP,
updated_by = $1,
updated_at = CURRENT_TIMESTAMP
WHERE user_id = $2 AND deleted_at IS NULL
`;
await pool.query(queryText, [approverId, userId]);
return true; // simple, cuma tanda berhasil
};
// Change user password
const changeUserPasswordDb = async (userId, newPassword) => {
const queryText = `
@@ -165,6 +181,7 @@ module.exports = {
getUserByUsernameDb,
createUserDb,
updateUserDb,
approveUserDb,
changeUserPasswordDb,
deleteUserDb,
};