column_setting.go
1.9 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
package domain
import "time"
// 栏目设置
type ColumnSetting struct {
// 栏目设置id
Id int64 `json:"id"`
// 栏目设置关联用户公司id
CompanyId int32 `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"`
}
type ColumnSettingRepository interface {
Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
Remove(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 columnSettingId, ok := data["columnSettingId"]; ok {
columnSetting.Id = columnSettingId.(int64)
}
if companyId, ok := data["companyId"]; ok {
columnSetting.CompanyId = companyId.(int32)
}
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)
}
return nil
}