Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
| | |
| | | return |
| | | } |
| | | |
| | | ids := make([]int, 0) |
| | | for _, product := range products { |
| | | ids = append(ids, product.CategoryId) |
| | | } |
| | | categories, err := models.NewProductCategorySearch().SetIds(ids).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品类型查找失败") |
| | | return |
| | | } |
| | | for _, product := range products { |
| | | for _, category := range categories { |
| | | if product.CategoryId == int(category.ID) { |
| | | product.CategoryName = category.Name |
| | | } |
| | | } |
| | | } |
| | | util.ResponseFormatList(c, code.Success, products, int(total)) |
| | | } |
| | | |
| | |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Ids []int |
| | | } |
| | | ) |
| | | |
| | |
| | | slf.Preload = preload |
| | | return slf |
| | | } |
| | | func (slf *ProductCategorySearch) SetIds(ids []int) *ProductCategorySearch { |
| | | slf.Ids = ids |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ProductCategorySearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ProductCategory{}) |
| | |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | if len(slf.Ids) > 0 { |
| | | db = db.Where("id in (?)", slf.Ids) |
| | | } |
| | | |
| | | return db |
| | | } |