From 0f8093693d0cd3b8da71abac95c617aa850f4819 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 22 四月 2024 15:44:55 +0800 Subject: [PATCH] 考勤管理 --- models/attendance_manage.go | 36 ++++++++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 10 deletions(-) diff --git a/models/attendance_manage.go b/models/attendance_manage.go index dac4b23..9a9f49e 100644 --- a/models/attendance_manage.go +++ b/models/attendance_manage.go @@ -2,7 +2,9 @@ import ( "fmt" + "github.com/shopspring/decimal" "gorm.io/gorm" + "silkserver/constvar" "silkserver/pkg/mysqlx" ) @@ -10,21 +12,26 @@ //AttendanceManage 鑰冨嫟绠$悊琛� AttendanceManage struct { gorm.Model - Date string `json:"date" gorm:"type:varchar(255);comment:鑰冨嫟鏃堕棿"` - WorkerId string `json:"workerId" gorm:"type:varchar(255);comment:浜哄憳id"` - WorkerName string `json:"workerName" gorm:"type:varchar(255);comment:浜哄憳濮撳悕"` - StartWorkTime string `json:"startWorkTime" gorm:"type:varchar(255);comment:涓婄彮鎵撳崱鏃堕棿"` - EndWorkTime string `json:"endWorkTime" gorm:"type:varchar(255);comment:涓嬬彮鎵撳崱鏃堕棿"` - Classes string `json:"classes" gorm:"type:varchar(255);comment:鐝"` - ClassesStartTime string `json:"classesStartTime" gorm:"type:varchar(255);comment:鐝寮�濮嬫椂闂�"` - ClassesEndTime string `json:"classesEndTime" gorm:"type:varchar(255);comment:鐝涓嬬彮鏃堕棿"` - CreateTime string `json:"createTime" gorm:"type:varchar(255);comment:娣诲姞鏃堕棿"` - AddPeople string `json:"addPeople" gorm:"type:varchar(255);comment:娣诲姞浜�"` + Date string `json:"date" gorm:"type:varchar(255);comment:鑰冨嫟鏃堕棿"` + WorkerId string `json:"workerId" gorm:"type:varchar(255);comment:浜哄憳id"` + WorkerName string `json:"workerName" gorm:"type:varchar(255);comment:浜哄憳濮撳悕"` + StartWorkTime string `json:"startWorkTime" gorm:"type:varchar(255);comment:涓婄彮鎵撳崱鏃堕棿"` + EndWorkTime string `json:"endWorkTime" gorm:"type:varchar(255);comment:涓嬬彮鎵撳崱鏃堕棿"` + Classes string `json:"classes" gorm:"type:varchar(255);comment:鐝"` + ClassesStartTime string `json:"classesStartTime" gorm:"type:varchar(255);comment:鐝寮�濮嬫椂闂�"` + ClassesEndTime string `json:"classesEndTime" gorm:"type:varchar(255);comment:鐝涓嬬彮鏃堕棿"` + CreateTime string `json:"createTime" gorm:"type:varchar(255);comment:娣诲姞鏃堕棿"` + AddPeople string `json:"addPeople" gorm:"type:varchar(255);comment:娣诲姞浜�"` + WorkTypeId uint `json:"workTypeId" gorm:"type:int(11);comment:宸ョid"` + WorkType WorkTypeManage `json:"workType" gorm:"foreignKey:WorkTypeId"` + Status constvar.AttendanceStatus `json:"status" gorm:"type:int(11);comment:鐘舵��"` + OverTimeDuration decimal.Decimal `json:"overTimeDuration" gorm:"type:decimal(20,2);comment:鍔犵彮鏃堕暱"` } AttendanceManageSearch struct { AttendanceManage PageNum int PageSize int + Preload bool Ids []uint Orm *gorm.DB } @@ -53,6 +60,11 @@ return slf } +func (slf *AttendanceManageSearch) SetPreload(preload bool) *AttendanceManageSearch { + slf.Preload = preload + return slf +} + func (slf *AttendanceManageSearch) build() *gorm.DB { var db = slf.Orm.Table(slf.TableName()) @@ -60,6 +72,10 @@ db = db.Where("id in (?)", slf.Ids) } + if slf.Preload { + db = db.Model(&AttendanceManage{}).Preload("WorkType") + } + return db } -- Gitblit v1.8.0