From c6ef67adba8b02fd2231ea7f95fc85e3bd02201a Mon Sep 17 00:00:00 2001 From: logan Date: Thu, 28 May 2026 20:50:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BB=84=E7=94=A8=E6=88=B7=E7=9C=8B=E4=B8=8D=E5=88=B0=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E7=9A=84bug=20=E2=80=94=20AccessibleInstances?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1Pluck=E8=A6=86=E7=9B=96=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E7=BB=93=E6=9E=9C=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8D=95=E6=9D=A1OR=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/handler/instance_extra.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/backend/internal/handler/instance_extra.go b/backend/internal/handler/instance_extra.go index f529cbc..d2000be 100644 --- a/backend/internal/handler/instance_extra.go +++ b/backend/internal/handler/instance_extra.go @@ -34,19 +34,10 @@ func AccessibleInstances(c *gin.Context) { return } var instanceIDs []int + // Query for the requested access_type OR readwrite (readwrite grants both) model.DB.Model(&model.InstanceGroupMember{}). - Where("group_id IN ? AND access_type = ?", groupIDs, accessType). + Where("group_id IN ? AND (access_type = ? OR access_type = ?)", groupIDs, accessType, "readwrite"). Pluck("instance_id", &instanceIDs) - // also include readwrite - if accessType == "readonly" { - model.DB.Model(&model.InstanceGroupMember{}). - Where("group_id IN ? AND access_type = ?", groupIDs, "readwrite"). - Pluck("instance_id", &instanceIDs) - } else if accessType == "write" { - model.DB.Model(&model.InstanceGroupMember{}). - Where("group_id IN ? AND access_type = ?", groupIDs, "readwrite"). - Pluck("instance_id", &instanceIDs) - } if len(instanceIDs) == 0 { c.JSON(http.StatusOK, []model.Instance{}) return