column_setting.go
3.2 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package domain
import "time"
// 默认选中栏目
var DefaultColumns = []Column{
{
Id: "index",
ParamCn: "序号",
ParamFix: 1,
}, {
Id: "orderId",
ParamCn: "订单号",
ParamFix: 1,
}, {
Id: "shipmentsId",
ParamCn: "发货单号",
ParamFix: 2,
}, {
Id: "saleDate",
ParamCn: "销售日期",
ParamFix: 2,
}, {
Id: "orderNum",
ParamCn: "订单数量",
ParamFix: 2,
}, {
Id: "quantityControl",
ParamCn: "数量调整",
ParamFix: 2,
}, {
Id: "orderPrice",
ParamCn: "订单金额",
ParamFix: 2,
}, {
Id: "priceControl",
ParamCn: "金额调整",
ParamFix: 2,
}, {
Id: "orderDist",
ParamCn: "订单区域",
ParamFix: 2,
}, {
Id: "partnerCategory",
ParamCn: "合伙人类型",
ParamFix: 2,
}, {
Id: "buyer",
ParamCn: "客户",
ParamFix: 2,
}, {
Id: "partner",
ParamCn: "合伙人",
ParamFix: 2,
},
}
// 默认未选中栏目
var DefaultInvalidColumns = []Column{
{
Id: "updateTime",
ParamCn: "更新时间",
ParamFix: 2,
}, {
Id: "createTime",
ParamCn: "创建时间",
ParamFix: 2,
},
}
// 栏目设置
type ColumnSetting struct {
// 栏目设置id
Id int64 `json:"id"`
// 栏目设置关联用户公司id
CompanyId int `json:"companyId"`
// 栏目设置创建时间
CreatedAt time.Time `json:"createdAt"`
// 栏目设置描述
Description string `json:"description"`
// 栏目设置模块名称
Key string `json:"key"`
// 栏目设置关联用户uid
Uid int64 `json:"uid"`
// 栏目设置更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 栏目设置关联用户名称
UserName string `json:"userName"`
// 有效栏目数组
Value []Column `json:"value"`
// 无效栏目数组
InvalidValue []Column `json:"invalidValue"`
}
type ColumnSettingRepository interface {
Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error)
FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error)
Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
}
func (columnSetting *ColumnSetting) Identify() interface{} {
if columnSetting.Id == 0 {
return nil
}
return columnSetting.Id
}
func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error {
if companyId, ok := data["companyId"]; ok {
columnSetting.CompanyId = companyId.(int)
}
if createdAt, ok := data["createdAt"]; ok {
columnSetting.CreatedAt = createdAt.(time.Time)
}
if description, ok := data["description"]; ok {
columnSetting.Description = description.(string)
}
if key, ok := data["key"]; ok {
columnSetting.Key = key.(string)
}
if uid, ok := data["uid"]; ok {
columnSetting.Uid = uid.(int64)
}
if updatedAt, ok := data["updatedAt"]; ok {
columnSetting.UpdatedAt = updatedAt.(time.Time)
}
if userName, ok := data["userName"]; ok {
columnSetting.UserName = userName.(string)
}
if value, ok := data["value"]; ok {
columnSetting.Value = value.([]Column)
}
if invalidValue, ok := data["invalidValue"]; ok {
columnSetting.InvalidValue = invalidValue.([]Column)
}
return nil
}