From e67802cd15e273da46bfb734e339a947b7d1eceb Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 15 九月 2023 16:01:04 +0800
Subject: [PATCH] debug
---
model/procedures.go | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/model/procedures.go b/model/procedures.go
index 3ca628f..99e45f4 100644
--- a/model/procedures.go
+++ b/model/procedures.go
@@ -16,6 +16,8 @@
WorkOrderID string `gorm:"index;type:varchar(191);not null;comment:宸ュ崟ID" json:"-"`
OrderID string `gorm:"index;type:varchar(191);not null;comment:璁㈠崟ID" json:"-"`
DeviceID string `gorm:"index;type:varchar(191);comment:璁惧ID" json:"deviceId"`
+ ProcedureID string `gorm:"index;type:varchar(191);comment:宸ュ簭ID" json:"procedureId"`
+ Position int `gorm:"type:int;comment:宸ヤ綔浣嶇疆" json:"position"` //姣忎釜璁惧鍙兘鏈夊涓満浣嶅悓鏃剁敓浜э紝鐢╬osition琛ㄧず浣嶇疆
StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
Status ProcedureStatus
@@ -32,6 +34,7 @@
Preload bool
StartTimeMax int64
StatusNot ProcedureStatus
+ ProcedureIds []string
}
)
@@ -83,6 +86,12 @@
slf.WorkOrderID = orderId
return slf
}
+
+func (slf *ProceduresSearch) SetProcedureId(id string) *ProceduresSearch {
+ slf.ProcedureID = id
+ return slf
+}
+
func (slf *ProceduresSearch) SetStartTimeMax(ts int64) *ProceduresSearch {
slf.StartTimeMax = ts
return slf
@@ -90,6 +99,11 @@
func (slf *ProceduresSearch) SetId(id int) *ProceduresSearch {
slf.ID = id
+ return slf
+}
+
+func (slf *ProceduresSearch) SetProcedureIds(procedureIds []string) *ProceduresSearch {
+ slf.ProcedureIds = procedureIds
return slf
}
@@ -148,6 +162,14 @@
db = db.Where("status <> ?", slf.StatusNot)
}
+ if len(slf.ProcedureIds) > 0 {
+ db = db.Where("procedure_id in ?", slf.ProcedureIds)
+ }
+
+ if slf.ProcedureID != "" {
+ db = db.Where("procedure_id = ?", slf.ProcedureID)
+ }
+
return db
}
@@ -173,10 +195,10 @@
return nil
}
-func (slf *ProceduresSearch) Save(record *Procedures) error {
+func (slf *ProceduresSearch) Updates(record *Procedures) error {
var db = slf.build()
- if err := db.Save(record).Error; err != nil {
+ if err := db.Updates(record).Error; err != nil {
return fmt.Errorf("save err: %v, record: %+v", err, record)
}
@@ -250,6 +272,17 @@
return records, total, nil
}
+func (slf *ProceduresSearch) Count() (int64, error) {
+ var (
+ total int64
+ db = slf.build()
+ )
+ if err := db.Count(&total).Error; err != nil {
+ return total, fmt.Errorf("find count err: %v", err)
+ }
+ return total, nil
+}
+
func (slf *ProceduresSearch) FindNotTotal() ([]*Procedures, error) {
var (
records = make([]*Procedures, 0)
--
Gitblit v1.8.0