| | |
| | | |
| | | DictSearch struct { |
| | | Dict |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | DictTypes []constvar.DictType |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DictSearch) SetDictTypes(dts []constvar.DictType) *DictSearch { |
| | | slf.DictTypes = dts |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DictSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Where("name like ? or number like ?", kw, kw) |
| | | } |
| | | |
| | | if len(slf.DictTypes) > 0 { |
| | | db = db.Where("dict_type in (?)", slf.DictTypes) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |