system_setting.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
package domain
// 系统参数设置
type SystemSetting struct {
// 公司id
CompanyId int64 `json:"companyId"`
// 管控层级
ControlLevel string `json:"controlLevel"`
// 描述
Description string `json:"description"`
// 设置对应的编码
SettingCode string `json:"settingCode"`
// 设置对应的名称
SettingName string `json:"settingName"`
// 数据id
SystemSettingId int64 `json:"systemSettingId"`
// 设定的值
Value string `json:"value"`
// 值类型
ValueType string `json:"valueType"`
}
type SystemSettingRepository interface {
Save(systemSetting *SystemSetting) (*SystemSetting, error)
Remove(systemSetting *SystemSetting) (*SystemSetting, error)
FindOne(queryOptions map[string]interface{}) (*SystemSetting, error)
Find(queryOptions map[string]interface{}) (int64, []*SystemSetting, error)
}
func (systemSetting *SystemSetting) Identify() interface{} {
if systemSetting.SystemSettingId == 0 {
return nil
}
return systemSetting.SystemSettingId
}
func (systemSetting *SystemSetting) Update(data map[string]interface{}) error {
if companyId, ok := data["companyId"]; ok {
systemSetting.CompanyId = companyId.(int64)
}
if controlLevel, ok := data["controlLevel"]; ok {
systemSetting.ControlLevel = controlLevel.(string)
}
if description, ok := data["description"]; ok {
systemSetting.Description = description.(string)
}
if settingCode, ok := data["settingCode"]; ok {
systemSetting.SettingCode = settingCode.(string)
}
if settingName, ok := data["settingName"]; ok {
systemSetting.SettingName = settingName.(string)
}
if systemSettingId, ok := data["systemSettingId"]; ok {
systemSetting.SystemSettingId = systemSettingId.(int64)
}
if value, ok := data["value"]; ok {
systemSetting.Value = value.(string)
}
if valueType, ok := data["valueType"]; ok {
systemSetting.ValueType = valueType.(string)
}
return nil
}
var defaultsysSettingList = []SystemSetting{
{
ControlLevel: "系统级",
ValueType: "字符",
Value: "TL123456!",
SettingName: "用户初始化密码",
SettingCode: "XT001",
Description: "用于用户初始化设置初始化密码",
},
}
func (systemSetting *SystemSetting) GetDefaultSetting(settingCode string) []SystemSetting {
var list []SystemSetting
if len(settingCode) > 0 {
for i := range defaultsysSettingList {
if defaultsysSettingList[i].SettingCode == settingCode {
list = append(list, defaultsysSettingList[i])
}
}
} else {
list = make([]SystemSetting, len(defaultsysSettingList))
copy(list, defaultsysSettingList)
}
return list
}