product_material.go
2.5 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
89
90
91
92
93
package domain
import "time"
// 生产物料
type ProductMaterial struct {
// 物料ID
ProductMaterialId int `json:"productMaterialId"`
// 企业id
CompanyId int `json:"companyId"`
// 组织ID
OrgId int `json:"orgId"`
// 物料分组ID
ProductMaterialGroupId int `json:"productMaterialGroupId"`
// 物料编码
MaterialNumber string `json:"materialNumber"`
// 物料名称
MaterialName string `json:"materialName"`
// 物料属性
MaterialAttribute *MaterialAttribute `json:"materialAttribute"`
// 物料类别
MaterialCategory *MaterialCategory `json:"materialCategory"`
// 物料扩展
ProductMaterialExt *MaterialExt `json:"productMaterialExt"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 扩展
Ext *Ext `json:"ext"`
}
type ProductMaterialRepository interface {
Save(productMaterial *ProductMaterial) (*ProductMaterial, error)
Remove(productMaterial *ProductMaterial) (*ProductMaterial, error)
FindOne(queryOptions map[string]interface{}) (*ProductMaterial, error)
Find(queryOptions map[string]interface{}) (int64, []*ProductMaterial, error)
}
func (productMaterial *ProductMaterial) Identify() interface{} {
if productMaterial.ProductMaterialId == 0 {
return nil
}
return productMaterial.ProductMaterialId
}
func (productMaterial *ProductMaterial) Update(data map[string]interface{}) error {
return nil
}
type ProductMaterials []*ProductMaterial
func (productMaterials ProductMaterials) ToMapById() map[int]*ProductMaterial {
var mapProductMaterial = make(map[int]*ProductMaterial, 0)
for _, v := range productMaterials {
mapProductMaterial[v.ProductMaterialId] = v
}
return mapProductMaterial
}
func (productMaterials ProductMaterials) ToMapByNumber() map[string]*ProductMaterial {
var mapProductMaterial = make(map[string]*ProductMaterial, 0)
for _, v := range productMaterials {
mapProductMaterial[v.MaterialNumber] = v
}
return mapProductMaterial
}
// 10:资产,9:配置,2:自制,11:费用,12:模型,5:虚拟,7:一次性,13:产品系列 12:模型,3:委外,4:特征,6:服务,1:外购
var mapMaterialCategory = map[int]string{
1: "外购",
2: "自制",
3: "委外",
4: "特征",
5: "虚拟",
6: "服务",
7: "一次性",
8: "",
9: "配置",
10: "资产",
11: "费用",
12: "模型",
13: "产品系列",
}
func MaterialAttributeDescription(code int) string {
if v, ok := mapMaterialCategory[code]; ok {
return v
}
return ""
}