fix
wangpengfei
2023-08-11 4dd4ae617e7f37817d2c795ff011d73a67dc29bf
model/quotation.go
@@ -30,7 +30,7 @@
      Quotation
      Orm      *gorm.DB
      Keyword  string
      SearchMap map[string]interface{}
      OrderBy  string
      PageNum  int
      PageSize int
@@ -49,11 +49,23 @@
func (slf *QuotationSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&Quotation{})
   if slf.Keyword != "" {
      db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
   }
   if slf.Id != 0 {
      db = db.Where("id = ?", slf.Id)
   }
   if len(slf.SearchMap) > 0 {
      for key, value := range slf.SearchMap {
         switch v := value.(type) {
         case string:
            if key == "validity_date" {
               db = db.Where(key+" = ?", v)
            }
         case int:
            if key == "client_id" || key == "sale_chance_id" {
               db = db.Where(key+" = ?", v)
            }
         }
      }
   }
   return db
@@ -106,11 +118,6 @@
   return db.Updates(data).Error
}
func (slf *QuotationSearch) SetKeyword(keyword string) *QuotationSearch {
   slf.Keyword = keyword
   return slf
}
func (slf *QuotationSearch) SetPage(page, size int) *QuotationSearch {
   slf.PageNum, slf.PageSize = page, size
   return slf
@@ -120,3 +127,8 @@
   slf.OrderBy = order
   return slf
}
func (slf *QuotationSearch) SetSearchMap(searchMap map[string]interface{}) *QuotationSearch {
   slf.SearchMap = searchMap
   return slf
}