From c5a0eb549cba2cd358a2d0496c44f3a289f15d9c Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期一, 28 八月 2023 14:22:06 +0800
Subject: [PATCH] fix

---
 model/masterOrder.go |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/model/masterOrder.go b/model/masterOrder.go
index 6231b0b..f33fd6c 100644
--- a/model/masterOrder.go
+++ b/model/masterOrder.go
@@ -13,6 +13,7 @@
 		ClientId   int         `json:"client_id" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
 		Client     Client      `json:"client" gorm:"foreignKey:ClientId"`
 		MemberId   int         `json:"member_id" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+		Member     User        `json:"member" gorm:"foreignKey:MemberId"`
 		StartTime  *CustomTime `json:"start_time" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"`
 		EndTime    *CustomTime `json:"end_time" gorm:"column:end_time;type:datetime;comment:缁撴潫鏃堕棿"`
 		Money      float64     `json:"money" gorm:"column:money;type:decimal(10,2);comment:鎬婚噾棰�"`
@@ -56,11 +57,11 @@
 				}
 
 				if key == "client_name" {
-					db = db.Joins("Client").Where("client.name = ?", v)
+					db = db.Joins("Client").Where("Client.name = ?", v)
 				}
 
 				if key == "member_name" {
-					db = db.Joins("User").Where("User.username = ?", v)
+					db = db.Joins("Member").Where("Member.username = ?", v)
 				}
 			case int:
 			case float64:
@@ -107,11 +108,7 @@
 		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("Client").Find(&records).Error
+	err := db.Preload("Member").Preload("Client").Order("id desc").Find(&records).Error
 	return records, total, err
 }
 
@@ -134,3 +131,7 @@
 	slf.SearchMap = searchMap
 	return slf
 }
+func (slf *MasterOrderSearch) SetIds(ids []int) *MasterOrderSearch {
+	slf.Orm = slf.Orm.Where("id in (?)", ids)
+	return slf
+}

--
Gitblit v1.8.0