liujiandao
2023-09-27 b3a318b7f707ca49fa9127881bbe709654eaa761
models/material.go
@@ -77,11 +77,12 @@
      //MaterialTypes   []constvar.MaterialType
      Keyword string
      //SetTemplateType constvar.SetTemplateType
      Order    string
      PageNum  int
      PageSize int
      Ids      []string
      Orm      *gorm.DB
      Order       string
      PageNum     int
      PageSize    int
      Ids         []string
      Orm         *gorm.DB
      CategoryIds []int
   }
   IdAndName struct {
@@ -152,6 +153,15 @@
   slf.TemplateID = id
   return slf
}
func (slf *MaterialSearch) SetCategoryId(id int) *MaterialSearch {
   slf.CategoryId = id
   return slf
}
func (slf *MaterialSearch) SetCategoryIds(ids []int) *MaterialSearch {
   slf.CategoryIds = ids
   return slf
}
//
//func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch {
@@ -207,7 +217,7 @@
   //}
   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 != "" {
@@ -223,6 +233,12 @@
   if slf.IsSale {
      db = db.Where("is_sale = ?", 1)
   }
   if slf.CategoryId > 0 {
      db = db.Where("category_id = ?", slf.CategoryId)
   }
   if len(slf.CategoryIds) > 0 {
      db = db.Where("category_id in ?", slf.CategoryIds)
   }
   return db
}