Преглед изворни кода

fix: combine request for StdSelector init

0xJacky пре 1 година
родитељ
комит
aec519499f
1 измењених фајлова са 5 додато и 7 уклоњено
  1. 5 7
      api/cosy/list.go

+ 5 - 7
api/cosy/list.go

@@ -29,14 +29,12 @@ func (c *Ctx[T]) combineStdSelectorRequest() {
 		ID []int `json:"id"`
 	}
 
-	if err := c.ctx.ShouldBindJSON(&StdSelectorInitParams); err != nil {
-		logger.Error(err)
-		return
+	_ = c.ctx.ShouldBindJSON(&StdSelectorInitParams)
+	if len(StdSelectorInitParams.ID) > 0 {
+		c.GormScope(func(tx *gorm.DB) *gorm.DB {
+			return tx.Where(c.itemKey+" IN ?", StdSelectorInitParams.ID)
+		})
 	}
-
-	c.GormScope(func(tx *gorm.DB) *gorm.DB {
-		return tx.Where(c.itemKey+" IN ?", StdSelectorInitParams.ID)
-	})
 }
 
 func (c *Ctx[T]) result() (*gorm.DB, bool) {