| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetAreaId(areaId int) *LocationProductSearch { |
| | | slf.AreaId = areaId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProduct{}) |
| | | |
| | |
| | | |
| | | if len(slf.LocationIds) > 0 { |
| | | db = db.Where("location_id in (?)", slf.LocationIds) |
| | | } |
| | | |
| | | if slf.AreaId != 0 { |
| | | db = db.Where("area_id = ?", slf.AreaId) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) FirstRes() (*LocationProduct, *gorm.DB) { |
| | | var ( |
| | | record = new(LocationProduct) |
| | | db = slf.build() |
| | | ) |
| | | return record, db.First(record) |
| | | } |