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:
2026-03-31 21:52:15 +08:00
parent 4aa58b2f3d
commit f4d742de04
5 changed files with 106 additions and 8 deletions
+13
View File
@@ -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 {