product_attendance_record.go 4.6 KB
package domain

import "time"

// 生产考勤记录
type ProductAttendanceRecord struct {
	// 考勤记录ID
	ProductAttendanceId int `json:"productAttendanceId,omitempty"`
	// 组织ID
	OrgId int `json:"orgId,omitempty"`
	// 产品ID
	ProductId int `json:"productId,omitempty"`
	// 考勤类型 1.正常 2.支援
	AttendanceType int `json:"attendanceType,omitempty"`
	// 生产工人
	ProductWorker *User `json:"productWorker,omitempty"`
	// 工作位置
	WorkStation *WorkStation `json:"workStation,omitempty"`
	// 签到
	SignIn time.Time `json:"signIn,omitempty"`
	// 签退
	SignOut time.Time `json:"signOut,omitempty"`
	// 考勤状态 1.未审核 2:已审核 3.自动审核
	AttendanceStatus int `json:"attendanceStatus,omitempty"`
	// 工时(审核前)
	WorkTimeBefore float64 `json:"workTimeBefore,omitempty"`
	// 工时(审核后)
	WorkTimeAfter float64 `json:"workTimeAfter,omitempty"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt,omitempty"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt,omitempty"`
	// 扩展数据
	Ext *Ext `json:"ext,omitempty"`
}

type ProductAttendanceRecordRepository interface {
	Save(productAttendanceRecord *ProductAttendanceRecord) (*ProductAttendanceRecord, error)
	Remove(productAttendanceRecord *ProductAttendanceRecord) (*ProductAttendanceRecord, error)
	FindOne(queryOptions map[string]interface{}) (*ProductAttendanceRecord, error)
	Find(queryOptions map[string]interface{}) (int64, []*ProductAttendanceRecord, error)
}

func (productAttendanceRecord *ProductAttendanceRecord) Identify() interface{} {
	if productAttendanceRecord.ProductAttendanceId == 0 {
		return nil
	}
	return productAttendanceRecord.ProductAttendanceId
}

func (productAttendanceRecord *ProductAttendanceRecord) Update(data map[string]interface{}) error {
	if productAttendanceId, ok := data["productAttendanceId"]; ok {
		productAttendanceRecord.ProductAttendanceId = productAttendanceId.(int)
	}
	if orgId, ok := data["orgId"]; ok {
		productAttendanceRecord.OrgId = orgId.(int)
	}
	if productId, ok := data["productId"]; ok {
		productAttendanceRecord.ProductId = productId.(int)
	}
	if attendanceType, ok := data["attendanceType"]; ok {
		productAttendanceRecord.AttendanceType = attendanceType.(int)
	}
	if userId, ok := data["userId"]; ok {
		productAttendanceRecord.ProductWorker.UserId = userId.(int)
	}
	if userName, ok := data["userName"]; ok {
		productAttendanceRecord.ProductWorker.UserName = userName.(string)
	}
	if employeeType, ok := data["employeeType"]; ok {
		productAttendanceRecord.ProductWorker.EmployeeType = employeeType.(int)
	}
	if icCardNumber, ok := data["icCardNumber"]; ok {
		productAttendanceRecord.ProductWorker.IcCardNumber = icCardNumber.(string)
	}
	if avatar, ok := data["avatar"]; ok {
		productAttendanceRecord.ProductWorker.Avatar = avatar.(string)
	}
	if phone, ok := data["phone"]; ok {
		productAttendanceRecord.ProductWorker.Phone = phone.(string)
	}
	if workStationId, ok := data["workStationId"]; ok {
		productAttendanceRecord.WorkStation.WorkStationId = workStationId.(string)
	}
	if workshopId, ok := data["workshopId"]; ok {
		productAttendanceRecord.WorkStation.WorkshopId = workshopId.(int)
	}
	if workshopName, ok := data["workshopName"]; ok {
		productAttendanceRecord.WorkStation.WorkshopName = workshopName.(string)
	}
	if lineId, ok := data["lineId"]; ok {
		productAttendanceRecord.WorkStation.LineId = lineId.(int)
	}
	if lineName, ok := data["lineName"]; ok {
		productAttendanceRecord.WorkStation.LineName = lineName.(string)
	}
	if sectionId, ok := data["sectionId"]; ok {
		productAttendanceRecord.WorkStation.SectionId = sectionId.(int)
	}
	if sectionName, ok := data["sectionName"]; ok {
		productAttendanceRecord.WorkStation.SectionName = sectionName.(string)
	}
	if signIn, ok := data["signIn"]; ok {
		productAttendanceRecord.SignIn = signIn.(time.Time)
	}
	if signOut, ok := data["signOut"]; ok {
		productAttendanceRecord.SignOut = signOut.(time.Time)
	}
	if attendanceStatus, ok := data["attendanceStatus"]; ok {
		productAttendanceRecord.AttendanceStatus = attendanceStatus.(int)
	}
	if workTimeBefore, ok := data["workTimeBefore"]; ok {
		productAttendanceRecord.WorkTimeBefore = workTimeBefore.(float64)
	}
	if workTimeAfter, ok := data["workTimeAfter"]; ok {
		productAttendanceRecord.WorkTimeAfter = workTimeAfter.(float64)
	}
	if createdAt, ok := data["createdAt"]; ok {
		productAttendanceRecord.CreatedAt = createdAt.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		productAttendanceRecord.UpdatedAt = updatedAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		productAttendanceRecord.DeletedAt = deletedAt.(time.Time)
	}
	return nil
}