model/device.go
@@ -23,6 +23,7 @@ PageNum int PageSize int Orm *gorm.DB DeviceIDs []string } ) @@ -64,6 +65,11 @@ return slf } func (slf *DeviceSearch) SetDeviceIds(deviceIds []string) *DeviceSearch { slf.DeviceIDs = deviceIds return slf } func (slf *DeviceSearch) build() *gorm.DB { var db = slf.Orm.Table(slf.TableName()) @@ -75,6 +81,10 @@ db = db.Where("device_id = ?", slf.DeviceID) } if len(slf.DeviceIDs) != 0 { db = db.Where("device_id in (?)", slf.DeviceIDs) } if slf.Order != "" { db = db.Order(slf.Order) }