fix
wangpengfei
2023-08-02 dac214fa72dc2974954a4d8ee934695f548ad155
model/serviceFollowup.go
@@ -28,7 +28,13 @@
   ServiceFollowupSearch struct {
      ServiceFollowup
      Orm *gorm.DB
            Orm      *gorm.DB
      Keyword  string
      OrderBy  string
      PageNum  int
      PageSize int
   }
)
@@ -44,6 +50,9 @@
func (slf *ServiceFollowupSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&ServiceFollowup{})
   if slf.Keyword != "" {
      db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
   }
   if slf.Id != 0 {
      db = db.Where("id = ?", slf.Id)
   }
@@ -73,11 +82,23 @@
   return record, err
}
func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, error) {
func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, int64, error) {
   var db = slf.build()
   var records = make([]*ServiceFollowup, 0)
   var total int64
   if err := db.Count(&total).Error; err != nil {
      return records, total, err
   }
   if slf.PageNum > 0 && slf.PageSize > 0 {
      db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
   }
   if slf.PageNum > 0 && slf.PageSize > 0 {
      db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
   }
   err := db.Preload("CustomerServiceSheet").Find(&records).Error
   return records, err
   return records, total, err
}
func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch {
@@ -85,8 +106,19 @@
   return slf
}
// 合同类型 合同状态(服务合同)
// 付款方式 是否开票 账户(销售退款单)
// 退入仓库 状态(销售退货单)
// 报价单状态 (报价单)
// 可能性 币种 当前状态(销售机会)
func (slf *ServiceFollowupSearch) SetKeyword(keyword string) *ServiceFollowupSearch {
   slf.Keyword = keyword
   return slf
}
func (slf *ServiceFollowupSearch) SetPage(page, size int) *ServiceFollowupSearch {
   slf.PageNum, slf.PageSize = page, size
   return slf
}
func (slf *ServiceFollowupSearch) SetOrder(order string) *ServiceFollowupSearch {
   slf.OrderBy = order
   return slf
}