feat(user): add user modification API and handler
implement user modification functionality including: - new endpoint /userMgr/modify - database update function DBUpdateUser - request/response structures - handler with proper authentication and validation - updated API documentation - marked as completed in README checklist
This commit is contained in:
+13
@@ -346,6 +346,19 @@ func DBQuerySpecificUser(userID int) (User, error) { // Query user by ID
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func DBUpdateUser(userID int, username, passwd string) error {
|
||||
var err error
|
||||
if passwd == "" {
|
||||
_, err = db.Exec("UPDATE userLogin SET username = ? WHERE userID = ?", username, userID)
|
||||
} else {
|
||||
_, err = db.Exec("UPDATE userLogin SET username = ?, passwd = ? WHERE userID = ?", username, passwd, userID)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update user: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DBUpdateUserType (userID int, newType string) error {
|
||||
_, err := db.Exec("UPDATE userLogin SET type = ? WHERE userID = ?", newType, userID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user