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 | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/models/workshop_manage.go b/models/workshop_manage.go index 9516937..ca05716 100644 --- a/models/workshop_manage.go +++ b/models/workshop_manage.go @@ -29,7 +29,7 @@ ) func (slf WorkshopManage) TableName() string { - return "workshop_manage" + return "silk_workshop_manage" } func NewWorkshopManageSearch() *WorkshopManageSearch { @@ -56,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 @@ -75,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 { @@ -146,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