fix: crud user
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user