| | |
| | | |
| | | DeviceSearch struct { |
| | | Device |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | DeviceIDs []string |
| | | } |
| | | ) |
| | | |
| | |
| | | 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()) |
| | | |
| | |
| | | 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) |
| | | } |