| | |
| | | |
| | | LocationProductSearch struct { |
| | | LocationProduct |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | LocationIds []int |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetLocationIds(locationIds []int) *LocationProductSearch { |
| | | slf.LocationIds = locationIds |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProduct{}) |
| | | |
| | |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | if len(slf.LocationIds) > 0 { |
| | | db = db.Where("location_id in (?)", slf.LocationIds) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |