WiiCITMS/models/hr/leave.go
2025-11-07 14:14:34 +08:00

49 lines
2.0 KiB
Go

package hr
import (
"WiiGoLibrary/framework/db/v1/utils/mssql/unique"
"WiiGoLibrary/framework/db/v1/utils/tool"
"WiiGoLibrary/framework/hub/v1/dblib"
"time"
)
// 请假表名
const LeaveTable = "hr_u_leave"
// LeaveModel 请假模型定义
type LeaveModel struct {
RecordGuid unique.UUID `gorm:"column:RecordGuid;type:UNIQUEIDENTIFIER;primaryKey;not null;default:newid();" json:"RecordGuid"`
LeaveID int64 `gorm:"column:LeaveID;type:BIGINT;not null;" json:"LeaveID"`
StaffGuid unique.UUID `gorm:"column:StaffGuid;type:UNIQUEIDENTIFIER;index;not null;" json:"StaffGuid"`
LeaveType int16 `gorm:"column:LeaveType;type:SMALLINT;not null;" json:"LeaveType"` // 请假类型: 1-事假, 2-病假, 3-年假, 4-调休
StartTime time.Time `gorm:"column:StartTime;type:DATETIME;not null;" json:"StartTime"` // 请假开始时间
EndTime time.Time `gorm:"column:EndTime;type:DATETIME;not null;" json:"EndTime"` // 请假结束时间
Duration float32 `gorm:"column:Duration;type:FLOAT;not null;" json:"Duration"` // 请假时长(天)
Reason string `gorm:"column:Reason;type:NVARCHAR(255);" json:"Reason"` // 请假原因
RecordType int16 `gorm:"column:RecordType;not null;" json:"RecordType"`
RecordStatus int16 `gorm:"column:RecordStatus;not null;default:0;" json:"RecordStatus"`
CreateTime time.Time `gorm:"column:CreateTime;type:DATETIME;default:CURRENT_TIMESTAMP;<-:create;" json:"CreateTime"`
UpdateTime time.Time `gorm:"column:UpdateTime;type:DATETIME;default:CURRENT_TIMESTAMP;autoUpdateTime;" json:"UpdateTime"`
}
func init() {
dblib.DBIns.RegisterAutoMigrateModel(&LeaveModel{})
}
// TableName 返回表名
func (lm *LeaveModel) TableName() string {
return LeaveTable
}
// LeaveInstance 创建请假实例
func LeaveInstance() *LeaveModel {
return &LeaveModel{
RecordGuid: unique.NewV4(),
LeaveID: tool.GenerateID(),
StaffGuid: unique.NilUUID,
LeaveType: 1, // 默认事假
RecordType: 0,
RecordStatus: 0,
}
}