zhangqian
2024-04-10 46ecbd9f5a71c01df45e241c8d5795454dafe1f7
字典支持关键字搜索
6个文件已修改
30 ■■■■■ 已修改文件
controllers/dict.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/request/system_set.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/dict.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dict.go
@@ -122,7 +122,7 @@
    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, "查找失败")
controllers/request/system_set.go
@@ -8,6 +8,7 @@
type GetDictList struct {
    PageInfo
    DictType *constvar.DictType `json:"dictType" form:"dictType"` //字典类型
    Keyword  string             `json:"keyword" form:"keyword"`   //搜索关键字
}
type AddDict struct {
docs/docs.go
@@ -525,6 +525,12 @@
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "搜索关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
docs/swagger.json
@@ -513,6 +513,12 @@
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "搜索关键字",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
docs/swagger.yaml
@@ -1097,6 +1097,10 @@
        - DictTypeWorkshop
        - DictTypeColor
        - DictTypeSpec
      - description: 搜索关键字
        in: query
        name: keyword
        type: string
      - description: 页码
        in: query
        name: page
models/dict.go
@@ -23,6 +23,7 @@
        PageNum  int
        PageSize int
        Orm      *gorm.DB
        Keyword  string
    }
)
@@ -64,6 +65,11 @@
    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
@@ -92,6 +98,11 @@
        db = db.Where("name = ?", slf.Name)
    }
    if slf.Keyword != "" {
        kw := "%" + slf.Keyword + "%"
        db = db.Where("name like ? or number like ?", kw, kw)
    }
    return db
}