zhangqian
2023-08-25 11af32523705ea3e550abbb7477a8f176382e6f7
model/receipt.go
@@ -53,11 +53,32 @@
   }
}
func (slf *ReceiptSearch) SetSourceType(sourceType constvar.ReceiptSourceType) *ReceiptSearch {
   slf.SourceType = sourceType
   return slf
}
func (slf *ReceiptSearch) SetSourceId(sourceId int) *ReceiptSearch {
   slf.SourceId = sourceId
   return slf
}
func (slf *ReceiptSearch) SetPage(page, size int) *ReceiptSearch {
   slf.PageNum, slf.PageSize = page, size
   return slf
}
func (slf *ReceiptSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&Receipt{})
   if slf.Id != 0 {
      db = db.Where("id = ?", slf.Id)
   }
   if slf.SourceType != 0 {
      db = db.Where("source_type = ?", slf.SourceType)
   }
   if slf.SourceId != 0 {
      db = db.Where("source_id = ?", slf.SourceId)
   }
   return db
}