product_job.go
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package domain
import "time"
// 工位(车间-生产线-工段-工位)
type ProductJob struct {
// 工位ID
ProductJobId int `json:"productJobId,omitempty"`
// 企业id
CompanyId int `json:"companyId,omitempty"`
// 组织ID
OrgId int `json:"orgId,omitempty"`
// 工位名称
JobName string `json:"jobName,omitempty"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 工作位置
WorkStation *WorkStation `json:"workStation,omitempty"`
// 关联设备列表
RelatedDevices []int `json:"relatedDevices,omitempty"`
}
type ProductJobRepository interface {
Save(productJob *ProductJob) (*ProductJob, error)
Remove(productJob *ProductJob) (*ProductJob, error)
FindOne(queryOptions map[string]interface{}) (*ProductJob, error)
Find(queryOptions map[string]interface{}) (int64, []*ProductJob, error)
}
func (productJob *ProductJob) Identify() interface{} {
if productJob.ProductJobId == 0 {
return nil
}
return productJob.ProductJobId
}
func (productJob *ProductJob) Update(data map[string]interface{}) error {
if productJobId, ok := data["productJobId"]; ok {
productJob.ProductJobId = productJobId.(int)
}
if companyId, ok := data["companyId"]; ok {
productJob.CompanyId = companyId.(int)
}
if orgId, ok := data["orgId"]; ok {
productJob.OrgId = orgId.(int)
}
if jobName, ok := data["jobName"]; ok {
productJob.JobName = jobName.(string)
}
if createdAt, ok := data["createdAt"]; ok {
productJob.CreatedAt = createdAt.(time.Time)
}
if updatedAt, ok := data["updatedAt"]; ok {
productJob.UpdatedAt = updatedAt.(time.Time)
}
if deletedAt, ok := data["deletedAt"]; ok {
productJob.DeletedAt = deletedAt.(time.Time)
}
if workStationId, ok := data["workStationId"]; ok {
productJob.WorkStation.WorkStationId = workStationId.(string)
}
if workshopId, ok := data["workshopId"]; ok {
productJob.WorkStation.WorkshopId = workshopId.(int)
}
if workshopName, ok := data["workshopName"]; ok {
productJob.WorkStation.WorkshopName = workshopName.(string)
}
if lineId, ok := data["lineId"]; ok {
productJob.WorkStation.LineId = lineId.(int)
}
if lineName, ok := data["lineName"]; ok {
productJob.WorkStation.LineName = lineName.(string)
}
if sectionId, ok := data["sectionId"]; ok {
productJob.WorkStation.SectionId = sectionId.(int)
}
if sectionName, ok := data["sectionName"]; ok {
productJob.WorkStation.SectionName = sectionName.(string)
}
//if relatedDevices, ok := data["relatedDevices"]; ok {
// productJob.RelatedDevices = relatedDevices.(array)
//}
return nil
}