| | |
| | | //LocationProductIds []int |
| | | LocationIds []int |
| | | ProductIds []string |
| | | Ids []int |
| | | } |
| | | |
| | | LocationProductAmountWithOperation struct { |
| | |
| | | |
| | | func (slf *LocationProductAmountSearch) SetID(id int) *LocationProductAmountSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) SetIds(ids []int) *LocationProductAmountSearch { |
| | | slf.Ids = ids |
| | | return slf |
| | | } |
| | | |
| | |
| | | |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | if len(slf.Ids) > 0 { |
| | | db = db.Where("id in (?)", slf.Ids) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return record, db.First(&record) |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) Count() (int64, error) { |
| | | var ( |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |