From 7d06c6472f1acea6b2e49e7b8837bf555e94e219 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 07 五月 2024 16:21:06 +0800 Subject: [PATCH] fox --- models/workshop_manage.go | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-) diff --git a/models/workshop_manage.go b/models/workshop_manage.go index f1bdc07..ca05716 100644 --- a/models/workshop_manage.go +++ b/models/workshop_manage.go @@ -12,6 +12,7 @@ WorkshopManage struct { gorm.Model WorkshopNumber string `json:"workshopNumber" gorm:"type:varchar(255);comment:杞﹂棿缂栧彿"` + WorkshopName string `json:"workshopName" gorm:"type:varchar(255);comment:杞﹂棿鍚嶇О"` GroupNumber int `json:"groupNumber" gorm:"type:int(11);comment:缁勫埆"` StartCarNumber int `json:"startCarNumber" gorm:"type:int(11);comment:寮�濮嬭溅鍙�"` EndCarNumber int `json:"endCarNumber" gorm:"type:int(11);comment:缁撴潫杞﹀彿"` @@ -28,7 +29,7 @@ ) func (slf WorkshopManage) TableName() string { - return "workshop_manage" + return "silk_workshop_manage" } func NewWorkshopManageSearch() *WorkshopManageSearch { @@ -55,6 +56,11 @@ return slf } +func (slf *WorkshopManageSearch) SetWorkshopName(workshopName string) *WorkshopManageSearch { + slf.WorkshopName = workshopName + return slf +} + func (slf *WorkshopManageSearch) SetGroupNumber(groupNumber int) *WorkshopManageSearch { slf.GroupNumber = groupNumber return slf @@ -74,6 +80,10 @@ if slf.WorkshopNumber != "" { db = db.Where("workshop_number = ?", slf.WorkshopNumber) + } + + if slf.WorkshopName != "" { + db = db.Where("workshop_name = ?", slf.WorkshopName) } if slf.GroupNumber != 0 { @@ -129,7 +139,7 @@ func (slf *WorkshopManageSearch) Save(record *WorkshopManage) error { var db = slf.build() - if err := db.Save(record).Error; err != nil { + if err := db.Omit("CreatedAt").Save(record).Error; err != nil { return fmt.Errorf("save err: %v, record: %+v", err, record) } @@ -145,3 +155,15 @@ return nil } + +func (slf *WorkshopManageSearch) 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 +} -- Gitblit v1.8.0