| | |
| | | } |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) SetSourceType(sourceType constvar.InvoiceSourceType) *InvoiceSearch { |
| | | slf.SourceType = sourceType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) SetSourceId(sourceId int) *InvoiceSearch { |
| | | slf.SourceId = sourceId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *InvoiceSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Invoice{}) |
| | | 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 |
| | | } |
| | | |