| | |
| | | if params.PageInfo.Check() { |
| | | search.SetPage(params.Page, params.PageSize) |
| | | } |
| | | products, total, err := search.SetKeyword(params.KeyWord).SetOrder("created_at desc").Find() |
| | | products, total, err := search.SetKeyword(params.KeyWord).SetCategoryId(params.CategoryId).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | |
| | | "request.GetProductList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryId": { |
| | | "type": "integer" |
| | | }, |
| | | "keyWord": { |
| | | "type": "string" |
| | | }, |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | "request.GetProductList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "categoryId": { |
| | | "type": "integer" |
| | | }, |
| | | "keyWord": { |
| | | "type": "string" |
| | | }, |
| | |
| | | type: object |
| | | request.GetProductList: |
| | | properties: |
| | | categoryId: |
| | | type: integer |
| | | keyWord: |
| | | type: string |
| | | page: |
| | |
| | | slf.TemplateID = id |
| | | return slf |
| | | } |
| | | func (slf *MaterialSearch) SetCategoryId(id int) *MaterialSearch { |
| | | slf.CategoryId = id |
| | | return slf |
| | | } |
| | | |
| | | // |
| | | //func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch { |
| | |
| | | //} |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ? or id LIKE ? ", "%"+slf.Keyword+"%", "%"+slf.Keyword+"%") |
| | | db = db.Where("name LIKE ? ", "%"+slf.Keyword+"%") |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | if slf.IsSale { |
| | | db = db.Where("is_sale = ?", 1) |
| | | } |
| | | if slf.CategoryId > 0 { |
| | | db = db.Where("category_id = ?", slf.CategoryId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | |
| | | type GetProductList struct { |
| | | PageInfo |
| | | KeyWord string `json:"keyWord"` |
| | | KeyWord string `json:"keyWord"` |
| | | CategoryId int `json:"categoryId"` |
| | | } |
| | | |
| | | type QueryOperationList struct { |