| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetProductId(productId string) *LocationProductSearch { |
| | | slf.ProductId = productId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetLocationId(locationId int) *LocationProductSearch { |
| | | slf.LocationId = locationId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProduct{}) |
| | | |
| | |
| | | db = db.Model(&LocationProduct{}).Preload("Location").Preload("Area").Preload("ProductCategory").Preload("Product") |
| | | } |
| | | |
| | | if slf.LocationId != 0 { |
| | | db = db.Where("location_id = ?", slf.LocationId) |
| | | } |
| | | |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |