| | |
| | | if params.DictType != nil { |
| | | search = search.SetDictType(params.DictType) |
| | | } |
| | | list, err := search.FindAll() |
| | | list, err := search.SetKeyword(params.Keyword).FindAll() |
| | | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | |
| | | type GetDictList struct { |
| | | PageInfo |
| | | DictType *constvar.DictType `json:"dictType" form:"dictType"` //字典类型 |
| | | Keyword string `json:"keyword" form:"keyword"` //搜索关键字 |
| | | } |
| | | |
| | | type AddDict struct { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "搜索关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "搜索关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | - DictTypeWorkshop |
| | | - DictTypeColor |
| | | - DictTypeSpec |
| | | - description: 搜索关键字 |
| | | in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DictSearch) SetKeyword(keyword string) *DictSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *DictSearch) SetDictType(dt *constvar.DictType) *DictSearch { |
| | | slf.DictType = dt |
| | | return slf |
| | |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | kw := "%" + slf.Keyword + "%" |
| | | db = db.Where("name like ? or number like ?", kw, kw) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |