From f874e81b77282079398c22c67af754a23d260c91 Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期四, 25 七月 2024 11:42:01 +0800 Subject: [PATCH] 添加字段,工种添加工种编码,用于计算工资(id无法固定工种信息) --- models/yield_register_circle.go | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/models/yield_register_circle.go b/models/yield_register_circle.go index 7f089cc..44a83dd 100644 --- a/models/yield_register_circle.go +++ b/models/yield_register_circle.go @@ -22,7 +22,9 @@ } YieldRegisterCircleSearch struct { YieldRegisterCircle - Orm *gorm.DB + YieldRegisterIds []uint + Order string + Orm *gorm.DB } ) @@ -44,11 +46,29 @@ return slf } +func (slf *YieldRegisterCircleSearch) SetYieldRegisterIds(ids []uint) *YieldRegisterCircleSearch { + slf.YieldRegisterIds = ids + return slf +} + +func (slf *YieldRegisterCircleSearch) SetOrder(order string) *YieldRegisterCircleSearch { + slf.Order = order + return slf +} + func (slf *YieldRegisterCircleSearch) build() *gorm.DB { db := slf.Orm.Table(slf.TableName()) if slf.YieldRegisterId > 0 { db = db.Where("yield_register_id = ?", slf.YieldRegisterId) + } + + if len(slf.YieldRegisterIds) > 0 { + db = db.Where("yield_register_id in ?", slf.YieldRegisterIds) + } + + if slf.Order != "" { + db = db.Order(slf.Order) } return db @@ -70,7 +90,7 @@ db = slf.build() ) - if err := db.Find(&records).Error; err != nil { + if err := db.Order("car_number").Find(&records).Error; err != nil { return records, fmt.Errorf("find records err: %v", err) } -- Gitblit v1.8.0