refactor(database): make DBListFrpcInstances able to list all users' frpc instances but not single user

feat(frpcAct): user will get createdBy when query frpc instances on current server
docs(api): update related api documentation
This commit is contained in:
2026-03-12 22:41:17 +08:00
parent f2b07a7732
commit 49048597f2
4 changed files with 45 additions and 25 deletions
+2 -18
View File
@@ -40,19 +40,6 @@ type CreateInstanceRequest struct {
Additional map[string]interface{} `json:"additionalProperties"`
}
type FrpcInstance struct {
ID int
UserID int
Name string
ServerAddr string
ServerPort string
AuthMethod string
BootAtStart bool
RunUser string
ConfigPath string
CreatedAt time.Time
}
var frpcDB *sql.DB
func CloseFrpcDatabase() error {
@@ -610,11 +597,7 @@ func ListInstancesHandler(w http.ResponseWriter, r *http.Request) {
return
}
// rows, err := frpcDB.Query(`
// SELECT id, userID, name, serverAddr, serverPort, auth_method, bootAtStart, runUser, configPath, createdAt
// FROM frpcInstances WHERE userID = ?
// `, userID)
instanceList, err := DBListFrpcInstances(userID)
instanceList, err := DBListFrpcInstances()
if err != nil {
postLog.Error(fmt.Sprintf("[ListInstancesHandler] Failed to query instances: %v", err))
SendErrorResponse(w, http.StatusInternalServerError, "Failed to query instances")
@@ -633,6 +616,7 @@ func ListInstancesHandler(w http.ResponseWriter, r *http.Request) {
"runUser": instance.RunUser,
"configPath": instance.ConfigPath,
"createdAt": instance.CreatedAt,
"createdBy": instance.CreatedBy,
}
if userType == "visitor" {