| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | | } |