feat(user): add user type modification endpoint

- Implement new endpoint `/userMgr/modifyType` for updating user types
- Add database function DBUpdateUserType to handle type updates
- Include request validation and proper error handling
- Update API documentation with new endpoint details
This commit is contained in:
2026-03-30 14:22:15 +08:00
parent 67bea968c6
commit 4aa58b2f3d
4 changed files with 88 additions and 1 deletions
+8
View File
@@ -346,6 +346,14 @@ func DBQuerySpecificUser(userID int) (User, error) { // Query user by ID
return user, nil
}
func DBUpdateUserType (userID int, newType string) error {
_, err := db.Exec("UPDATE userLogin SET type = ? WHERE userID = ?", newType, userID)
if err != nil {
return fmt.Errorf("failed to update user type: %w", err)
}
return nil
}
func DBAddFrpcInstance(instance FrpcInstance) error {
_, err := frpcDB.Exec("INSERT INTO frpcInstances (userID, name, bootAtStart, runUser, configPath, createdAt) VALUES (?, ?, ?, ?, ?, ?)",
instance.UserID, instance.Name, instance.BootAtStart, instance.RunUser, instance.ConfigPath, time.Now().Format(time.RFC3339))